diff options
author | George Hazan <ghazan@miranda.im> | 2018-02-21 18:38:18 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2018-02-21 18:40:14 +0300 |
commit | 007e02e4152c7282af4b8f844d927f223ce6f69f (patch) | |
tree | 5e652d95f8227853cd7dce2551ef014d078a6ae5 /src/core | |
parent | beb15c0662d6e31237f32983f7e58141054277c5 (diff) |
StdMsg: C++'11 iterators
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/stdmsg/src/chat_manager.cpp | 4 | ||||
-rw-r--r-- | src/core/stdmsg/src/cmdlist.cpp | 11 | ||||
-rw-r--r-- | src/core/stdmsg/src/globals.cpp | 4 | ||||
-rw-r--r-- | src/core/stdmsg/src/msgdialog.cpp | 4 | ||||
-rw-r--r-- | src/core/stdmsg/src/msgs.cpp | 9 | ||||
-rw-r--r-- | src/core/stdmsg/src/tabs.cpp | 6 |
6 files changed, 15 insertions, 23 deletions
diff --git a/src/core/stdmsg/src/chat_manager.cpp b/src/core/stdmsg/src/chat_manager.cpp index b96eda5f6d..f2763fc919 100644 --- a/src/core/stdmsg/src/chat_manager.cpp +++ b/src/core/stdmsg/src/chat_manager.cpp @@ -46,11 +46,9 @@ SESSION_INFO* SM_GetNextWindow(SESSION_INFO *si) if (i == -1) return nullptr; - for (i++; i < pci->arSessions.getCount(); i++) { - SESSION_INFO *p = pci->arSessions[i]; + for (auto &p : pci->arSessions) if (p->pDlg) return p; - } return nullptr; } diff --git a/src/core/stdmsg/src/cmdlist.cpp b/src/core/stdmsg/src/cmdlist.cpp index 85b72de8fe..32e6049de4 100644 --- a/src/core/stdmsg/src/cmdlist.cpp +++ b/src/core/stdmsg/src/cmdlist.cpp @@ -41,8 +41,8 @@ static VOID CALLBACK MsgTimer(HWND, UINT, UINT_PTR, DWORD dwTime) }
}
- for (int i = 0; i < arTimedOut.getCount(); ++i)
- MessageFailureProcess(arTimedOut[i], LPGEN("The message send timed out."));
+ for (auto &it : arTimedOut)
+ MessageFailureProcess(it, LPGEN("The message send timed out."));
}
void msgQueue_add(MCONTACT hContact, int id, char *szMsg, int flags)
@@ -113,10 +113,9 @@ void msgQueue_processack(MCONTACT hContact, int id, BOOL success, const char *sz void msgQueue_destroy(void)
{
- for (int i = 0; i < msgQueue.getCount(); i++) {
- TMsgQueue *item = msgQueue[i];
- mir_free(item->szMsg);
- mir_free(item);
+ for (auto &it : msgQueue) {
+ mir_free(it->szMsg);
+ mir_free(it);
}
msgQueue.destroy();
}
diff --git a/src/core/stdmsg/src/globals.cpp b/src/core/stdmsg/src/globals.cpp index f5c20cd409..01aa85af7b 100644 --- a/src/core/stdmsg/src/globals.cpp +++ b/src/core/stdmsg/src/globals.cpp @@ -42,11 +42,9 @@ static int IconsChanged(WPARAM, LPARAM) static int OnShutdown(WPARAM, LPARAM)
{
- for (int i = 0; i < pci->arSessions.getCount(); i++) {
- SESSION_INFO *si = pci->arSessions[i];
+ for (auto &si : pci->arSessions)
if (si->pDlg)
si->pDlg->Close();
- }
UninitTabs();
ImageList_Destroy(hIconsList);
diff --git a/src/core/stdmsg/src/msgdialog.cpp b/src/core/stdmsg/src/msgdialog.cpp index 6215e1d55a..59bd5898a1 100644 --- a/src/core/stdmsg/src/msgdialog.cpp +++ b/src/core/stdmsg/src/msgdialog.cpp @@ -278,8 +278,8 @@ void CSrmmWindow::OnDestroy() if (m_hStatusIcon)
IcoLib_ReleaseIcon(m_hStatusIcon);
- for (int i = 0; i < m_cmdList.getCount(); i++)
- mir_free(m_cmdList[i]);
+ for (auto &it : m_cmdList)
+ mir_free(it);
m_cmdList.destroy();
MCONTACT hContact = (g_dat.bSavePerContact) ? m_hContact : 0;
diff --git a/src/core/stdmsg/src/msgs.cpp b/src/core/stdmsg/src/msgs.cpp index 2933bbf669..0b99c01edc 100644 --- a/src/core/stdmsg/src/msgs.cpp +++ b/src/core/stdmsg/src/msgs.cpp @@ -274,11 +274,10 @@ static void RestoreUnreadMessageAlerts(void) cle.flags = CLEF_UNICODE;
cle.szTooltip.w = toolTip;
- for (int i = 0; i < arEvents.getCount(); i++) {
- MSavedEvent &e = arEvents[i];
- mir_snwprintf(toolTip, TranslateT("Message from %s"), pcli->pfnGetContactDisplayName(e.hContact, 0));
- cle.hContact = e.hContact;
- cle.hDbEvent = e.hEvent;
+ for (auto &e : arEvents) {
+ mir_snwprintf(toolTip, TranslateT("Message from %s"), pcli->pfnGetContactDisplayName(e->hContact, 0));
+ cle.hContact = e->hContact;
+ cle.hDbEvent = e->hEvent;
pcli->pfnAddEvent(&cle);
}
}
diff --git a/src/core/stdmsg/src/tabs.cpp b/src/core/stdmsg/src/tabs.cpp index 78ba5ba02a..0e33116897 100644 --- a/src/core/stdmsg/src/tabs.cpp +++ b/src/core/stdmsg/src/tabs.cpp @@ -96,10 +96,8 @@ void CTabbedWindow::OnInitDialog() // restore previous tabs if (g_Settings.bTabRestore) { - for (int i = 0; i < arSavedTabs.getCount(); i++) { - CSavedTab &p = arSavedTabs[i]; - - SESSION_INFO *si = pci->SM_FindSession(p.m_id, p.m_szModule); + for (auto &p : arSavedTabs) { + SESSION_INFO *si = pci->SM_FindSession(p->m_id, p->m_szModule); if (si) AddPage(si); } |