Premature return if message list/set is empty.

This commit is contained in:
Vincent Richard 2014-03-10 20:00:24 +01:00
parent 3fcea19d75
commit 642cdf42f6
3 changed files with 18 additions and 0 deletions

View File

@ -767,6 +767,9 @@ void IMAPFolder::fetchMessages(std::vector <shared_ptr <message> >& msg, const f
else if (!isOpen())
throw exceptions::illegal_state("Folder not open");
if (msg.empty())
return;
// Build message numbers list
std::vector <int> list;
list.reserve(msg.size());
@ -870,6 +873,9 @@ std::vector <shared_ptr <message> > IMAPFolder::getAndFetchMessages
else if (!isOpen())
throw exceptions::illegal_state("Folder not open");
if (msgs.isEmpty())
return std::vector <shared_ptr <message> >();
// Ensure we also get the UID for each message
fetchAttributes attribsWithUID(attribs);
attribsWithUID.add(fetchAttributes::UID);

View File

@ -1187,6 +1187,9 @@ void maildirFolder::fetchMessages(std::vector <shared_ptr <message> >& msg,
else if (!isOpen())
throw exceptions::illegal_state("Folder not open");
if (msg.empty())
return;
const size_t total = msg.size();
size_t current = 0;
@ -1226,6 +1229,9 @@ void maildirFolder::fetchMessage(shared_ptr <message> msg, const fetchAttributes
std::vector <shared_ptr <message> > maildirFolder::getAndFetchMessages
(const messageSet& msgs, const fetchAttributes& attribs)
{
if (msgs.isEmpty())
return std::vector <shared_ptr <message> >();
std::vector <shared_ptr <message> > messages = getMessages(msgs);
fetchMessages(messages, attribs);

View File

@ -315,6 +315,9 @@ void POP3Folder::fetchMessages(std::vector <shared_ptr <message> >& msg, const f
else if (!isOpen())
throw exceptions::illegal_state("Folder not open");
if (msg.empty())
return;
const size_t total = msg.size();
size_t current = 0;
@ -487,6 +490,9 @@ void POP3Folder::fetchMessage(shared_ptr <message> msg, const fetchAttributes& o
std::vector <shared_ptr <message> > POP3Folder::getAndFetchMessages
(const messageSet& msgs, const fetchAttributes& attribs)
{
if (msgs.isEmpty())
return std::vector <shared_ptr <message> >();
std::vector <shared_ptr <message> > messages = getMessages(msgs);
fetchMessages(messages, attribs);