Skip to content

Commit

Permalink
Code optimization.
Browse files Browse the repository at this point in the history
  • Loading branch information
mobizt committed Aug 20, 2023
1 parent 2c7de1f commit 23c9369
Show file tree
Hide file tree
Showing 13 changed files with 47 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,10 @@ void printAllMailboxesInfo(IMAPSession &imap);
void printSelectedMailboxInfo(SelectedFolderInfo sFolder);

/* Print all messages from the message list */
void printMessages(MB_VECTOR<IMAP_MSG_Item> &msgItems, bool headerOnly);
void printMessages(std::vector<IMAP_MSG_Item> &msgItems, bool headerOnly);

/* Print all attachments info from the message */
void printAttacements(MB_VECTOR<IMAP_Attach_Item> &atts);
void printAttacements(std::vector<IMAP_Attach_Item> &atts);

/* Declare the global used IMAPSession object for IMAP transport */
IMAPSession imap;
Expand Down Expand Up @@ -389,7 +389,7 @@ void printSelectedMailboxInfo(SelectedFolderInfo sFolder)
}
}

void printAttacements(MB_VECTOR<IMAP_Attach_Item> &atts)
void printAttacements(std::vector<IMAP_Attach_Item> &atts)
{
MailClient.printf("Attachment: %d file(s)\n****************************\n", atts.size());
for (size_t j = 0; j < atts.size(); j++)
Expand All @@ -405,7 +405,7 @@ void printAttacements(MB_VECTOR<IMAP_Attach_Item> &atts)
Serial.println();
}

void printMessages(MB_VECTOR<IMAP_MSG_Item> &msgItems, bool headerOnly)
void printMessages(std::vector<IMAP_MSG_Item> &msgItems, bool headerOnly)
{

/** In devices other than ESP8266 and ESP32, if SD card was chosen as filestorage and
Expand Down
8 changes: 4 additions & 4 deletions examples/IMAP/External_Client/External_Client.ino
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ void printAllMailboxesInfo(IMAPSession &imap);

void printSelectedMailboxInfo(SelectedFolderInfo sFolder);

void printMessages(MB_VECTOR<IMAP_MSG_Item> &msgItems, bool headerOnly);
void printMessages(std::vector<IMAP_MSG_Item> &msgItems, bool headerOnly);

void printAttacements(MB_VECTOR<IMAP_Attach_Item> &atts);
void printAttacements(std::vector<IMAP_Attach_Item> &atts);

IMAPSession imap;

Expand Down Expand Up @@ -240,7 +240,7 @@ void printSelectedMailboxInfo(SelectedFolderInfo sFolder)
}
}

void printAttacements(MB_VECTOR<IMAP_Attach_Item> &atts)
void printAttacements(std::vector<IMAP_Attach_Item> &atts)
{
MailClient.printf("Attachment: %d file(s)\n****************************\n", atts.size());
for (size_t j = 0; j < atts.size(); j++)
Expand All @@ -251,7 +251,7 @@ void printAttacements(MB_VECTOR<IMAP_Attach_Item> &atts)
Serial.println();
}

void printMessages(MB_VECTOR<IMAP_MSG_Item> &msgItems, bool headerOnly)
void printMessages(std::vector<IMAP_MSG_Item> &msgItems, bool headerOnly)
{

for (size_t i = 0; i < msgItems.size(); i++)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,10 @@ void printAllMailboxesInfo(IMAPSession &imap);
void printSelectedMailboxInfo(SelectedFolderInfo sFolder);

/* Print all messages from the message list */
void printMessages(MB_VECTOR<IMAP_MSG_Item> &msgItems, bool headerOnly);
void printMessages(std::vector<IMAP_MSG_Item> &msgItems, bool headerOnly);

/* Print all attachments info from the message */
void printAttacements(MB_VECTOR<IMAP_Attach_Item> &atts);
void printAttacements(std::vector<IMAP_Attach_Item> &atts);

/* Declare the global used IMAPSession object for IMAP transport */
IMAPSession imap;
Expand Down Expand Up @@ -355,7 +355,7 @@ void printSelectedMailboxInfo(SelectedFolderInfo sFolder)
}
}

void printAttacements(MB_VECTOR<IMAP_Attach_Item> &atts)
void printAttacements(std::vector<IMAP_Attach_Item> &atts)
{
MailClient.printf("Attachment: %d file(s)\n****************************\n", atts.size());
for (size_t j = 0; j < atts.size(); j++)
Expand All @@ -371,7 +371,7 @@ void printAttacements(MB_VECTOR<IMAP_Attach_Item> &atts)
Serial.println();
}

void printMessages(MB_VECTOR<IMAP_MSG_Item> &msgItems, bool headerOnly)
void printMessages(std::vector<IMAP_MSG_Item> &msgItems, bool headerOnly)
{

/** In devices other than ESP8266 and ESP32, if SD card was chosen as filestorage and
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,10 @@ void printAllMailboxesInfo(IMAPSession &imap);
void printSelectedMailboxInfo(SelectedFolderInfo sFolder);

/* Print all messages from the message list */
void printMessages(MB_VECTOR<IMAP_MSG_Item> &msgItems, bool headerOnly);
void printMessages(std::vector<IMAP_MSG_Item> &msgItems, bool headerOnly);

/* Print all attachments info from the message */
void printAttacements(MB_VECTOR<IMAP_Attach_Item> &atts);
void printAttacements(std::vector<IMAP_Attach_Item> &atts);

/* Declare the global used IMAPSession object for IMAP transport */
IMAPSession imap;
Expand Down Expand Up @@ -347,7 +347,7 @@ void printSelectedMailboxInfo(SelectedFolderInfo sFolder)
}
}

void printAttacements(MB_VECTOR<IMAP_Attach_Item> &atts)
void printAttacements(std::vector<IMAP_Attach_Item> &atts)
{
MailClient.printf("Attachment: %d file(s)\n****************************\n", atts.size());
for (size_t j = 0; j < atts.size(); j++)
Expand All @@ -363,7 +363,7 @@ void printAttacements(MB_VECTOR<IMAP_Attach_Item> &atts)
Serial.println();
}

void printMessages(MB_VECTOR<IMAP_MSG_Item> &msgItems, bool headerOnly)
void printMessages(std::vector<IMAP_MSG_Item> &msgItems, bool headerOnly)
{

for (size_t i = 0; i < msgItems.size(); i++)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,10 @@ void printAllMailboxesInfo(IMAPSession &imap);
void printSelectedMailboxInfo(SelectedFolderInfo sFolder);

/* Print all messages from the message list */
void printMessages(MB_VECTOR<IMAP_MSG_Item> &msgItems, bool headerOnly);
void printMessages(std::vector<IMAP_MSG_Item> &msgItems, bool headerOnly);

/* Print all attachments info from the message */
void printAttacements(MB_VECTOR<IMAP_Attach_Item> &atts);
void printAttacements(std::vector<IMAP_Attach_Item> &atts);

/* Declare the global used IMAPSession object for IMAP transport */
IMAPSession imap;
Expand Down Expand Up @@ -363,7 +363,7 @@ void printSelectedMailboxInfo(SelectedFolderInfo sFolder)
}
}

void printAttacements(MB_VECTOR<IMAP_Attach_Item> &atts)
void printAttacements(std::vector<IMAP_Attach_Item> &atts)
{
MailClient.printf("Attachment: %d file(s)\n****************************\n", atts.size());
for (size_t j = 0; j < atts.size(); j++)
Expand All @@ -379,7 +379,7 @@ void printAttacements(MB_VECTOR<IMAP_Attach_Item> &atts)
Serial.println();
}

void printMessages(MB_VECTOR<IMAP_MSG_Item> &msgItems, bool headerOnly)
void printMessages(std::vector<IMAP_MSG_Item> &msgItems, bool headerOnly)
{

/** In devices other than ESP8266 and ESP32, if SD card was chosen as filestorage and
Expand Down
8 changes: 4 additions & 4 deletions examples/IMAP/Read_Sequence_Set/Read_Sequence_Set.ino
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@ void printAllMailboxesInfo(IMAPSession &imap);
void printSelectedMailboxInfo(SelectedFolderInfo sFolder);

/* Print all messages from the message list */
void printMessages(MB_VECTOR<IMAP_MSG_Item> &msgItems, bool headerOnly);
void printMessages(std::vector<IMAP_MSG_Item> &msgItems, bool headerOnly);

/* Print all attachments info from the message */
void printAttacements(MB_VECTOR<IMAP_Attach_Item> &atts);
void printAttacements(std::vector<IMAP_Attach_Item> &atts);

/* Declare the Session_Config for user defined session credentials */
Session_Config config;
Expand Down Expand Up @@ -368,7 +368,7 @@ void printSelectedMailboxInfo(SelectedFolderInfo sFolder)
}
}

void printAttacements(MB_VECTOR<IMAP_Attach_Item> &atts)
void printAttacements(std::vector<IMAP_Attach_Item> &atts)
{
MailClient.printf("Attachment: %d file(s)\n****************************\n", atts.size());
for (size_t j = 0; j < atts.size(); j++)
Expand All @@ -384,7 +384,7 @@ void printAttacements(MB_VECTOR<IMAP_Attach_Item> &atts)
Serial.println();
}

void printMessages(MB_VECTOR<IMAP_MSG_Item> &msgItems, bool headerOnly)
void printMessages(std::vector<IMAP_MSG_Item> &msgItems, bool headerOnly)
{

/** In devices other than ESP8266 and ESP32, if SD card was chosen as filestorage and
Expand Down
8 changes: 4 additions & 4 deletions examples/IMAP/Read_Single_Email/Read_Single_Email.ino
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,10 @@ void printAllMailboxesInfo(IMAPSession &imap);
void printSelectedMailboxInfo(SelectedFolderInfo sFolder);

/* Print all messages from the message list */
void printMessages(MB_VECTOR<IMAP_MSG_Item> &msgItems, bool headerOnly);
void printMessages(std::vector<IMAP_MSG_Item> &msgItems, bool headerOnly);

/* Print all attachments info from the message */
void printAttacements(MB_VECTOR<IMAP_Attach_Item> &atts);
void printAttacements(std::vector<IMAP_Attach_Item> &atts);

/* Declare the global used IMAPSession object for IMAP transport */
IMAPSession imap;
Expand Down Expand Up @@ -407,7 +407,7 @@ void printSelectedMailboxInfo(SelectedFolderInfo sFolder)
}
}

void printAttacements(MB_VECTOR<IMAP_Attach_Item> &atts)
void printAttacements(std::vector<IMAP_Attach_Item> &atts)
{
MailClient.printf("Attachment: %d file(s)\n****************************\n", atts.size());
for (size_t j = 0; j < atts.size(); j++)
Expand All @@ -423,7 +423,7 @@ void printAttacements(MB_VECTOR<IMAP_Attach_Item> &atts)
Serial.println();
}

void printMessages(MB_VECTOR<IMAP_MSG_Item> &msgItems, bool headerOnly)
void printMessages(std::vector<IMAP_MSG_Item> &msgItems, bool headerOnly)
{

/** In devices other than ESP8266 and ESP32, if SD card was chosen as filestorage and
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,10 @@ void printAllMailboxesInfo(IMAPSession &imap);
void printSelectedMailboxInfo(SelectedFolderInfo sFolder);

/* Print all messages from the message list */
void printMessages(MB_VECTOR<IMAP_MSG_Item> &msgItems, bool headerOnly);
void printMessages(std::vector<IMAP_MSG_Item> &msgItems, bool headerOnly);

/* Print all attachments info from the message */
void printAttacements(MB_VECTOR<IMAP_Attach_Item> &atts);
void printAttacements(std::vector<IMAP_Attach_Item> &atts);

/* Declare the global used IMAPSession object for IMAP transport */
IMAPSession imap;
Expand Down Expand Up @@ -453,7 +453,7 @@ void printSelectedMailboxInfo(SelectedFolderInfo sFolder)
}
}

void printAttacements(MB_VECTOR<IMAP_Attach_Item> &atts)
void printAttacements(std::vector<IMAP_Attach_Item> &atts)
{
MailClient.printf("Attachment: %d file(s)\n****************************\n", atts.size());
for (size_t j = 0; j < atts.size(); j++)
Expand All @@ -469,7 +469,7 @@ void printAttacements(MB_VECTOR<IMAP_Attach_Item> &atts)
Serial.println();
}

void printMessages(MB_VECTOR<IMAP_MSG_Item> &msgItems, bool headerOnly)
void printMessages(std::vector<IMAP_MSG_Item> &msgItems, bool headerOnly)
{
/** In devices other than ESP8266 and ESP32, if SD card was chosen as filestorage and
* the standard SD.h library included in ESP_Mail_FS.h, files will be renamed due to long filename
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ void printAllMailboxesInfo(IMAPSession &imap);

void printSelectedMailboxInfo(SelectedFolderInfo sFolder);

void printMessages(MB_VECTOR<IMAP_MSG_Item> &msgItems, bool headerOnly);
void printMessages(std::vector<IMAP_MSG_Item> &msgItems, bool headerOnly);

void printAttacements(MB_VECTOR<IMAP_Attach_Item> &atts);
void printAttacements(std::vector<IMAP_Attach_Item> &atts);

IMAPSession imap;

Expand Down Expand Up @@ -307,7 +307,7 @@ void printSelectedMailboxInfo(SelectedFolderInfo sFolder)
}
}

void printAttacements(MB_VECTOR<IMAP_Attach_Item> &atts)
void printAttacements(std::vector<IMAP_Attach_Item> &atts)
{
MailClient.printf("Attachment: %d file(s)\n****************************\n", atts.size());
for (size_t j = 0; j < atts.size(); j++)
Expand All @@ -318,7 +318,7 @@ void printAttacements(MB_VECTOR<IMAP_Attach_Item> &atts)
Serial.println();
}

void printMessages(MB_VECTOR<IMAP_MSG_Item> &msgItems, bool headerOnly)
void printMessages(std::vector<IMAP_MSG_Item> &msgItems, bool headerOnly)
{

for (size_t i = 0; i < msgItems.size(); i++)
Expand Down
8 changes: 4 additions & 4 deletions examples/IMAP/Search_Emails/Search_Emails.ino
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,10 @@ void printAllMailboxesInfo(IMAPSession &imap);
void printSelectedMailboxInfo(SelectedFolderInfo sFolder);

/* Print all messages from the message list */
void printMessages(MB_VECTOR<IMAP_MSG_Item> &msgItems, bool headerOnly);
void printMessages(std::vector<IMAP_MSG_Item> &msgItems, bool headerOnly);

/* Print all attachments info from the message */
void printAttacements(MB_VECTOR<IMAP_Attach_Item> &atts);
void printAttacements(std::vector<IMAP_Attach_Item> &atts);

/* Declare the global used IMAPSession object for IMAP transport */
IMAPSession imap;
Expand Down Expand Up @@ -429,7 +429,7 @@ void printSelectedMailboxInfo(SelectedFolderInfo sFolder)
}
}

void printAttacements(MB_VECTOR<IMAP_Attach_Item> &atts)
void printAttacements(std::vector<IMAP_Attach_Item> &atts)
{
MailClient.printf("Attachment: %d file(s)\n****************************\n", atts.size());
for (size_t j = 0; j < atts.size(); j++)
Expand All @@ -445,7 +445,7 @@ void printAttacements(MB_VECTOR<IMAP_Attach_Item> &atts)
Serial.println();
}

void printMessages(MB_VECTOR<IMAP_MSG_Item> &msgItems, bool headerOnly)
void printMessages(std::vector<IMAP_MSG_Item> &msgItems, bool headerOnly)
{

for (size_t i = 0; i < msgItems.size(); i++)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ void printAllMailboxesInfo(IMAPSession &imap);

void printSelectedMailboxInfo(SelectedFolderInfo sFolder);

void printMessages(MB_VECTOR<IMAP_MSG_Item> &msgItems, bool headerOnly);
void printMessages(std::vector<IMAP_MSG_Item> &msgItems, bool headerOnly);

void printAttacements(MB_VECTOR<IMAP_Attach_Item> &atts);
void printAttacements(std::vector<IMAP_Attach_Item> &atts);

IMAPSession imap;

Expand Down Expand Up @@ -232,7 +232,7 @@ void printSelectedMailboxInfo(SelectedFolderInfo sFolder)
}
}

void printAttacements(MB_VECTOR<IMAP_Attach_Item> &atts)
void printAttacements(std::vector<IMAP_Attach_Item> &atts)
{
MailClient.printf("Attachment: %d file(s)\n****************************\n", atts.size());
for (size_t j = 0; j < atts.size(); j++)
Expand All @@ -243,7 +243,7 @@ void printAttacements(MB_VECTOR<IMAP_Attach_Item> &atts)
Serial.println();
}

void printMessages(MB_VECTOR<IMAP_MSG_Item> &msgItems, bool headerOnly)
void printMessages(std::vector<IMAP_MSG_Item> &msgItems, bool headerOnly)
{

for (size_t i = 0; i < msgItems.size(); i++)
Expand Down
1 change: 0 additions & 1 deletion src/ESP_Mail_Client.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
#include <algorithm>
#include <string>
#include <vector>
#define _vectorImpl std::vector

#if __has_include(<string.h>)
#include <string.h>
Expand Down
5 changes: 3 additions & 2 deletions src/ESP_Mail_Const.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@
#define ESP_MAIL_DEFAULT_DEBUG_PORT Serial
#endif

#if !defined(__AVR__)
#include <vector>
#include <algorithm>
#endif

#define _vectorImpl std::vector
#define MB_VECTOR std::vector

#if !defined(FPSTR)
#define FPSTR
Expand Down

0 comments on commit 23c9369

Please sign in to comment.