diff options
author | George Hazan <ghazan@miranda.im> | 2018-03-16 12:09:30 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2018-03-16 12:09:38 +0300 |
commit | a7e5e613f86963c8bf82248ab044e0ea36e42fbc (patch) | |
tree | 39e0e6b3ab4bcb55255302d3d1e989b31247bf7b /src | |
parent | ecbca42677af470d672e66d3f6950af208f8f212 (diff) |
LIST<>::indexOf(T**) - fast index calculation for direct iterators
Diffstat (limited to 'src')
-rw-r--r-- | src/mir_app/src/FontOptions.cpp | 68 | ||||
-rw-r--r-- | src/mir_app/src/chat_manager.cpp | 7 | ||||
-rw-r--r-- | src/mir_app/src/clistevents.cpp | 10 | ||||
-rw-r--r-- | src/mir_app/src/clisttray.cpp | 6 | ||||
-rw-r--r-- | src/mir_app/src/db_ini.cpp | 7 | ||||
-rw-r--r-- | src/mir_app/src/iconheader.cpp | 2 | ||||
-rw-r--r-- | src/mir_app/src/menu_clist.cpp | 6 | ||||
-rw-r--r-- | src/mir_app/src/netlib.cpp | 4 | ||||
-rw-r--r-- | src/mir_app/src/netliblog.cpp | 8 | ||||
-rw-r--r-- | src/mir_app/src/netlibopts.cpp | 27 | ||||
-rw-r--r-- | src/mir_app/src/options.cpp | 20 | ||||
-rw-r--r-- | src/mir_app/src/proto_chains.cpp | 6 | ||||
-rw-r--r-- | src/mir_app/src/proto_order.cpp | 22 | ||||
-rw-r--r-- | src/mir_app/src/skin2opts.cpp | 5 | ||||
-rw-r--r-- | src/mir_core/src/timezones.cpp | 23 |
15 files changed, 112 insertions, 109 deletions
diff --git a/src/mir_app/src/FontOptions.cpp b/src/mir_app/src/FontOptions.cpp index bce42d268c..9d42904807 100644 --- a/src/mir_app/src/FontOptions.cpp +++ b/src/mir_app/src/FontOptions.cpp @@ -599,16 +599,16 @@ static INT_PTR CALLBACK DlgProcLogOptions(HWND hwndDlg, UINT msg, WPARAM wParam, SendDlgItemMessage(hwndDlg, IDC_FONTLIST, WM_SETREDRAW, FALSE, 0);
- for (int fontId = 0; fontId < font_id_list_w2.getCount(); fontId++) {
- FontInternal &F = font_id_list_w2[fontId];
- if (!wcsncmp(F.group, group_buff, 64)) {
- FSUIListItemData *itemData = (FSUIListItemData*)mir_alloc(sizeof(FSUIListItemData));
- itemData->colour_id = -1;
- itemData->effect_id = -1;
- itemData->font_id = fontId;
- SendDlgItemMessage(hwndDlg, IDC_FONTLIST, LB_ADDSTRING, (WPARAM)-1, (LPARAM)itemData);
- need_restart |= (F.flags & FIDF_NEEDRESTART);
- }
+ for (auto &it : font_id_list_w2) {
+ if (wcsncmp(it->group, group_buff, 64))
+ continue;
+
+ FSUIListItemData *itemData = (FSUIListItemData*)mir_alloc(sizeof(FSUIListItemData));
+ itemData->colour_id = -1;
+ itemData->effect_id = -1;
+ itemData->font_id = font_id_list_w2.indexOf(&it);
+ SendDlgItemMessage(hwndDlg, IDC_FONTLIST, LB_ADDSTRING, (WPARAM)-1, (LPARAM)itemData);
+ need_restart |= (it->flags & FIDF_NEEDRESTART);
}
if (hBkgColourBrush) {
@@ -616,37 +616,39 @@ static INT_PTR CALLBACK DlgProcLogOptions(HWND hwndDlg, UINT msg, WPARAM wParam, hBkgColourBrush = nullptr;
}
- for (int colourId = 0; colourId < colour_id_list_w2.getCount(); colourId++) {
- ColourInternal &C = colour_id_list_w2[colourId];
- if (!wcsncmp(C.group, group_buff, 64)) {
- if (!sttFsuiBindColourIdToFonts(GetDlgItem(hwndDlg, IDC_FONTLIST), C.name, C.group, C.name, colourId)) {
- FSUIListItemData *itemData = (FSUIListItemData*)mir_alloc(sizeof(FSUIListItemData));
- itemData->colour_id = colourId;
- itemData->font_id = -1;
- itemData->effect_id = -1;
+ for (auto &it : colour_id_list_w2) {
+ if (wcsncmp(it->group, group_buff, 64))
+ continue;
- SendDlgItemMessage(hwndDlg, IDC_FONTLIST, LB_ADDSTRING, (WPARAM)-1, (LPARAM)itemData);
- }
+ int colourId = colour_id_list_w2.indexOf(&it);
+ if (!sttFsuiBindColourIdToFonts(GetDlgItem(hwndDlg, IDC_FONTLIST), it->name, it->group, it->name, colourId)) {
+ FSUIListItemData *itemData = (FSUIListItemData*)mir_alloc(sizeof(FSUIListItemData));
+ itemData->colour_id = colourId;
+ itemData->font_id = -1;
+ itemData->effect_id = -1;
- if (mir_wstrcmp(C.name, L"Background") == 0)
- hBkgColourBrush = CreateSolidBrush(C.value);
+ SendDlgItemMessage(hwndDlg, IDC_FONTLIST, LB_ADDSTRING, (WPARAM)-1, (LPARAM)itemData);
}
+
+ if (mir_wstrcmp(it->name, L"Background") == 0)
+ hBkgColourBrush = CreateSolidBrush(it->value);
}
if (!hBkgColourBrush)
hBkgColourBrush = CreateSolidBrush(GetSysColor(COLOR_WINDOW));
- for (int effectId = 0; effectId < effect_id_list_w2.getCount(); effectId++) {
- EffectInternal& E = effect_id_list_w2[effectId];
- if (!wcsncmp(E.group, group_buff, 64)) {
- if (!sttFsuiBindEffectIdToFonts(GetDlgItem(hwndDlg, IDC_FONTLIST), E.name, effectId)) {
- FSUIListItemData *itemData = (FSUIListItemData*)mir_alloc(sizeof(FSUIListItemData));
- itemData->effect_id = effectId;
- itemData->font_id = -1;
- itemData->colour_id = -1;
-
- SendDlgItemMessage(hwndDlg, IDC_FONTLIST, LB_ADDSTRING, (WPARAM)-1, (LPARAM)itemData);
- }
+ for (auto &it : effect_id_list_w2) {
+ if (wcsncmp(it->group, group_buff, 64))
+ continue;
+
+ int effectId = effect_id_list_w2.indexOf(&it);
+ if (!sttFsuiBindEffectIdToFonts(GetDlgItem(hwndDlg, IDC_FONTLIST), it->name, effectId)) {
+ FSUIListItemData *itemData = (FSUIListItemData*)mir_alloc(sizeof(FSUIListItemData));
+ itemData->effect_id = effectId;
+ itemData->font_id = -1;
+ itemData->colour_id = -1;
+
+ SendDlgItemMessage(hwndDlg, IDC_FONTLIST, LB_ADDSTRING, (WPARAM)-1, (LPARAM)itemData);
}
}
diff --git a/src/mir_app/src/chat_manager.cpp b/src/mir_app/src/chat_manager.cpp index 0feb9f65b7..55c42c9d42 100644 --- a/src/mir_app/src/chat_manager.cpp +++ b/src/mir_app/src/chat_manager.cpp @@ -385,10 +385,9 @@ BOOL SM_ChangeNick(const wchar_t *pszID, const char *pszModule, GCEVENT *gce) void SM_RemoveAll(void)
{
- while (g_arSessions.getCount()) {
- SM_FreeSession(g_arSessions[0], false);
- g_arSessions.remove(0);
- }
+ for (auto &it : g_arSessions)
+ SM_FreeSession(it, false);
+ g_arSessions.destroy();
}
static void SM_AddCommand(const wchar_t *pszID, const char *pszModule, const char* lpNewCommand)
diff --git a/src/mir_app/src/clistevents.cpp b/src/mir_app/src/clistevents.cpp index f9a7130108..c000f1462f 100644 --- a/src/mir_app/src/clistevents.cpp +++ b/src/mir_app/src/clistevents.cpp @@ -99,7 +99,9 @@ static void ShowOneEventInTray(int idx) static void ShowEventsInTray()
{
int nTrayCnt = cli.trayIconCount;
- if (!g_cliEvents.getCount() || !nTrayCnt) return;
+ if (!g_cliEvents.getCount() || !nTrayCnt)
+ return;
+
if (g_cliEvents.getCount() == 1 || nTrayCnt == 1) {
ShowOneEventInTray(0); //for only one icon in tray show topmost event
return;
@@ -133,7 +135,7 @@ static VOID CALLBACK IconFlashTimer(HWND, UINT, UINT_PTR idEvent, DWORD) {
ShowEventsInTray();
- for (int i=0; i < g_cliEvents.getCount(); i++) {
+ for (int i = 0; i < g_cliEvents.getCount(); i++) {
auto &e = g_cliEvents[i];
int j;
for (j = 0; j < i; j++)
@@ -141,7 +143,7 @@ static VOID CALLBACK IconFlashTimer(HWND, UINT, UINT_PTR idEvent, DWORD) break;
if (j >= i)
cli.pfnChangeContactIcon(e.hContact, iconsOn || disableIconFlash ? e.imlIconIndex : 0);
-
+
// decrease eflashes in any case - no need to collect all events
if (e.flags & CLEF_ONLYAFEW)
if (0 >= --e.flashesDone)
@@ -257,7 +259,7 @@ CLISTEVENT* fnGetEvent(MCONTACT hContact, int idx) if (it->hContact == hContact)
if (idx-- == 0)
return it;
-
+
return nullptr;
}
diff --git a/src/mir_app/src/clisttray.cpp b/src/mir_app/src/clisttray.cpp index 8ef2039e5f..6fb2866dc1 100644 --- a/src/mir_app/src/clisttray.cpp +++ b/src/mir_app/src/clisttray.cpp @@ -470,9 +470,9 @@ void fnTrayIconUpdateBase(const char *szChangedProto) cli.cycleTimerId = 0;
}
- for (int i = 0; i < accounts.getCount(); i++)
- if (!mir_strcmp(szChangedProto, accounts[i]->szModuleName))
- cli.cycleStep = i;
+ for (auto &it : accounts)
+ if (!mir_strcmp(szChangedProto, it->szModuleName))
+ cli.cycleStep = accounts.indexOf(&it);
int changed = cli.pfnTrayCalcChanged(szChangedProto, averageMode, netProtoCount);
if (changed != -1 && cli.trayIcon[changed].isBase)
diff --git a/src/mir_app/src/db_ini.cpp b/src/mir_app/src/db_ini.cpp index 34acedeb5c..d37a374e85 100644 --- a/src/mir_app/src/db_ini.cpp +++ b/src/mir_app/src/db_ini.cpp @@ -426,10 +426,9 @@ LBL_NewLine: ESFDParam param = { &arSettings, szName };
db_enum_settings(0, EnumSettingsForDeletion, szSection, ¶m);
- while (arSettings.getCount()) {
- db_unset(0, szSection, arSettings[0]);
- mir_free(arSettings[0]);
- arSettings.remove(0);
+ for (auto &it : arSettings) {
+ db_unset(0, szSection, it);
+ mir_free(it);
}
}
db_unset(0, szSection, szName);
diff --git a/src/mir_app/src/iconheader.cpp b/src/mir_app/src/iconheader.cpp index 4a00cbfd48..beb7c9fbcb 100644 --- a/src/mir_app/src/iconheader.cpp +++ b/src/mir_app/src/iconheader.cpp @@ -415,7 +415,7 @@ static LRESULT CALLBACK MIcoTabWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, L newIdx--;
break;
}
- if ((newIdx >= 0) && (newIdx < itc->pList.getCount()) && (newIdx != itc->nSelectedIdx)) {
+ if (newIdx >= 0 && newIdx < itc->pList.getCount() && newIdx != itc->nSelectedIdx) {
itc->nSelectedIdx = newIdx;
SetWindowText(hwndDlg, itc->pList[itc->nSelectedIdx]->tcsName);
RedrawWindow(hwndDlg, nullptr, nullptr, RDW_INVALIDATE);
diff --git a/src/mir_app/src/menu_clist.cpp b/src/mir_app/src/menu_clist.cpp index 6b4a3a1e1f..a7d1718498 100644 --- a/src/mir_app/src/menu_clist.cpp +++ b/src/mir_app/src/menu_clist.cpp @@ -766,9 +766,9 @@ int fnGetProtoIndexByPos(PROTOCOLDESCRIPTOR **proto, int protoCnt, int Pos) int fnGetAccountIndexByPos(int Pos)
{
- for (int i = 0; i < accounts.getCount(); i++)
- if (accounts[i]->iOrder == Pos)
- return i;
+ for (auto &it : accounts)
+ if (it->iOrder == Pos)
+ return accounts.indexOf(&it);
return -1;
}
diff --git a/src/mir_app/src/netlib.cpp b/src/mir_app/src/netlib.cpp index 9f22ad933b..64f76962bb 100644 --- a/src/mir_app/src/netlib.cpp +++ b/src/mir_app/src/netlib.cpp @@ -393,8 +393,8 @@ void UnloadNetlibModule(void) DestroyHookableEvent(hRecvEvent); hRecvEvent = nullptr;
DestroyHookableEvent(hSendEvent); hSendEvent = nullptr;
- for (int i = netlibUser.getCount(); i > 0; i--)
- Netlib_CloseHandle(netlibUser[i-1]);
+ for (auto &it : netlibUser.rev_iter())
+ Netlib_CloseHandle(it);
CloseHandle(hConnectionHeaderMutex);
if (hConnectionOpenMutex)
diff --git a/src/mir_app/src/netliblog.cpp b/src/mir_app/src/netliblog.cpp index 6bb9fc32a3..391fb5e38f 100644 --- a/src/mir_app/src/netliblog.cpp +++ b/src/mir_app/src/netliblog.cpp @@ -127,10 +127,10 @@ static INT_PTR CALLBACK LogOptionsDlgProc(HWND hwndDlg, UINT message, WPARAM wPa tvis.item.mask = TVIF_PARAM | TVIF_TEXT | TVIF_STATE;
tvis.item.stateMask = TVIS_STATEIMAGEMASK;
- for (int i = 0; i < netlibUser.getCount(); i++) {
- tvis.item.pszText = netlibUser[i]->user.szDescriptiveName.w;
- tvis.item.lParam = i;
- tvis.item.state = INDEXTOSTATEIMAGEMASK((netlibUser[i]->toLog) ? 2 : 1);
+ for (auto &it : netlibUser) {
+ tvis.item.pszText = it->user.szDescriptiveName.w;
+ tvis.item.lParam = netlibUser.indexOf(&it);
+ tvis.item.state = INDEXTOSTATEIMAGEMASK(it->toLog ? 2 : 1);
TreeView_InsertItem(hwndFilter, &tvis);
}
tvis.item.lParam = -1;
diff --git a/src/mir_app/src/netlibopts.cpp b/src/mir_app/src/netlibopts.cpp index a9aef9ae86..2672778a9b 100644 --- a/src/mir_app/src/netlibopts.cpp +++ b/src/mir_app/src/netlibopts.cpp @@ -262,20 +262,19 @@ static INT_PTR CALLBACK DlgProcNetlibOpts(HWND hwndDlg, UINT msg, WPARAM wParam, int iItem = SendDlgItemMessage(hwndDlg, IDC_NETLIBUSERS, CB_ADDSTRING, 0, (LPARAM)TranslateT("<All connections>"));
SendDlgItemMessage(hwndDlg, IDC_NETLIBUSERS, CB_SETITEMDATA, iItem, (LPARAM)-1);
SendDlgItemMessage(hwndDlg, IDC_NETLIBUSERS, CB_SETCURSEL, iItem, 0);
- {
- mir_cslock lck(csNetlibUser);
- for (int i = 0; i < netlibUser.getCount(); ++i) {
- NetlibTempSettings *thisSettings = (NetlibTempSettings*)mir_calloc(sizeof(NetlibTempSettings));
- thisSettings->flags = netlibUser[i]->user.flags;
- thisSettings->szSettingsModule = mir_strdup(netlibUser[i]->user.szSettingsModule);
- CopySettingsStruct(&thisSettings->settings, &netlibUser[i]->settings);
- tempSettings.insert(thisSettings);
-
- if (netlibUser[i]->user.flags & NUF_NOOPTIONS)
- continue;
- iItem = SendDlgItemMessage(hwndDlg, IDC_NETLIBUSERS, CB_ADDSTRING, 0, (LPARAM)netlibUser[i]->user.szDescriptiveName.w);
- SendDlgItemMessage(hwndDlg, IDC_NETLIBUSERS, CB_SETITEMDATA, iItem, i);
- }
+
+ mir_cslock lck(csNetlibUser);
+ for (auto &it : netlibUser) {
+ NetlibTempSettings *thisSettings = (NetlibTempSettings*)mir_calloc(sizeof(NetlibTempSettings));
+ thisSettings->flags = it->user.flags;
+ thisSettings->szSettingsModule = mir_strdup(it->user.szSettingsModule);
+ CopySettingsStruct(&thisSettings->settings, &it->settings);
+ tempSettings.insert(thisSettings);
+
+ if (it->user.flags & NUF_NOOPTIONS)
+ continue;
+ iItem = SendDlgItemMessage(hwndDlg, IDC_NETLIBUSERS, CB_ADDSTRING, 0, (LPARAM)it->user.szDescriptiveName.w);
+ SendDlgItemMessage(hwndDlg, IDC_NETLIBUSERS, CB_SETITEMDATA, iItem, netlibUser.indexOf(&it));
}
}
diff --git a/src/mir_app/src/options.cpp b/src/mir_app/src/options.cpp index ad7876ecca..9280d29cd6 100644 --- a/src/mir_app/src/options.cpp +++ b/src/mir_app/src/options.cpp @@ -582,7 +582,9 @@ class COptionsDlg : public CDlgBase else {
tvi.hItem = FindNamedTreeItem(nullptr, useTitle);
if (tvi.hItem != nullptr) {
- if (i == m_currentPage) m_hCurrentPage = tvi.hItem;
+ if (i == m_currentPage)
+ m_hCurrentPage = tvi.hItem;
+
tvi.mask = TVIF_PARAM;
m_pageTree.GetItem(&tvi);
if (tvi.lParam == -1) {
@@ -754,17 +756,16 @@ public: else
lastTab = mir_wstrdup(m_szTab);
- for (int i = 0; i < m_pages.getCount(); i++) {
- const OPTIONSDIALOGPAGE &odp = m_pages[i];
- OptionsPageData *opd = new OptionsPageData(odp);
+ for (auto &it : m_pages) {
+ OptionsPageData *opd = new OptionsPageData(*it);
if (opd->pDialog == nullptr) // smth went wrong
delete opd;
else
m_arOpd.insert(opd);
- if (!mir_wstrcmp(lastPage, odp.szTitle.w) && !mir_wstrcmp(lastGroup, odp.szGroup.w))
- if ((m_szTab == nullptr && m_currentPage == -1) || !mir_wstrcmp(lastTab, odp.szTab.w))
- m_currentPage = i;
+ if (!mir_wstrcmp(lastPage, it->szTitle.w) && !mir_wstrcmp(lastGroup, it->szGroup.w))
+ if ((m_szTab == nullptr && m_currentPage == -1) || !mir_wstrcmp(lastTab, it->szTab.w))
+ m_currentPage = m_pages.indexOf(&it);
}
GetWindowRect(GetDlgItem(m_hwnd, IDC_STNOPAGE), &m_rcDisplay);
@@ -839,8 +840,7 @@ public: PSHNOTIFY pshn = {};
pshn.hdr.code = PSN_APPLY;
- for (int i = 0; i < m_arOpd.getCount(); i++) {
- OptionsPageData *p = m_arOpd[i];
+ for (auto &p : m_arOpd) {
if (p->getHwnd() == nullptr || !p->changed)
continue;
@@ -852,7 +852,7 @@ public: m_pageTree.SelectItem(m_hCurrentPage);
if (opd)
opd->pDialog->Hide();
- m_currentPage = i;
+ m_currentPage = m_arOpd.indexOf(&p);
if (opd)
opd->pDialog->Show();
return;
diff --git a/src/mir_app/src/proto_chains.cpp b/src/mir_app/src/proto_chains.cpp index 0855cdc8e3..6bfb1df0a9 100644 --- a/src/mir_app/src/proto_chains.cpp +++ b/src/mir_app/src/proto_chains.cpp @@ -170,9 +170,9 @@ MIR_APP_DLL(int) Proto_IsProtoOnContact(MCONTACT hContact, const char *szProto) if (!_stricmp(szProto, szContactProto))
return -1;
- for (int i = 0; i < filters.getCount(); i++)
- if (!mir_strcmp(szProto, filters[i]->szName))
- return i + 1;
+ for (auto &it : filters)
+ if (!mir_strcmp(szProto, it->szName))
+ return filters.indexOf(&it) + 1;
return 0;
}
diff --git a/src/mir_app/src/proto_order.cpp b/src/mir_app/src/proto_order.cpp index b35c115385..020f5e9d4c 100644 --- a/src/mir_app/src/proto_order.cpp +++ b/src/mir_app/src/proto_order.cpp @@ -42,26 +42,30 @@ int isProtoSuitable(PROTO_INTERFACE* ppi) bool CheckProtocolOrder(void)
{
bool changed = false;
- int i, id = 0;
+ int id = 0;
for (;;) {
// Find account with this id
- for (i = 0; i < accounts.getCount(); i++)
- if (accounts[i]->iOrder == id)
+ bool bFound = false;
+ for (auto &pa : accounts)
+ if (pa->iOrder == id) {
+ bFound = true;
break;
+ }
// Account with id not found
- if (i == accounts.getCount()) {
+ if (!bFound) {
// Check if this is skipped id, if it is decrement all other ids
- bool found = false;
for (auto &pa : accounts) {
if (pa->iOrder < 1000000 && pa->iOrder > id) {
--pa->iOrder;
- found = true;
+ bFound = true;
}
}
- if (found) changed = true;
- else break;
+ if (!bFound)
+ break;
+
+ changed = true;
}
else id++;
}
@@ -77,7 +81,7 @@ bool CheckProtocolOrder(void) if (id < accounts.getCount()) {
// Remove duplicate ids
- for (i = 0; i < accounts.getCount(); i++) {
+ for (int i = 0; i < accounts.getCount(); i++) {
bool found = false;
for (int j = 0; j < accounts.getCount(); j++) {
if (accounts[j]->iOrder == i) {
diff --git a/src/mir_app/src/skin2opts.cpp b/src/mir_app/src/skin2opts.cpp index a3c9b06e19..b1401cc07f 100644 --- a/src/mir_app/src/skin2opts.cpp +++ b/src/mir_app/src/skin2opts.cpp @@ -783,15 +783,14 @@ public: {
mir_cslock lck(csIconList);
- for (int indx = 0; indx < iconList.getCount(); indx++) {
- IcolibItem *item = iconList[indx];
+ for (auto &item : iconList) {
if (item->section == sectionActive) {
lvi.pszText = item->getDescr();
HICON hIcon = item->temp_icon;
if (!hIcon)
hIcon = IconItem_GetIcon_Preview(item);
lvi.iImage = ImageList_AddIcon(hIml, hIcon);
- lvi.lParam = indx;
+ lvi.lParam = iconList.indexOf(&item);
m_preview.InsertItem(&lvi);
if (hIcon != item->temp_icon)
SafeDestroyIcon(hIcon);
diff --git a/src/mir_core/src/timezones.cpp b/src/mir_core/src/timezones.cpp index a4e74b1eb0..a6b972ae38 100644 --- a/src/mir_core/src/timezones.cpp +++ b/src/mir_core/src/timezones.cpp @@ -400,15 +400,16 @@ MIR_CORE_DLL(int) TimeZone_SelectListItem(MCONTACT hContact, LPCSTR szModule, HW if (lstMsg == nullptr)
return -1;
- if (szModule == nullptr) szModule = "UserInfo";
+ if (szModule == nullptr)
+ szModule = "UserInfo";
int iSelection = 0;
ptrW tszName(db_get_wsa(hContact, szModule, "TzName"));
if (tszName != NULL) {
unsigned hash = mir_hashstrT(tszName);
- for (int i = 0; i < g_timezonesBias.getCount(); i++) {
- if (hash == g_timezonesBias[i]->hash) {
- iSelection = i + 1;
+ for (auto &it : g_timezonesBias) {
+ if (hash == it->hash) {
+ iSelection = g_timezonesBias.indexOf(&it) + 1;
break;
}
}
@@ -417,9 +418,9 @@ MIR_CORE_DLL(int) TimeZone_SelectListItem(MCONTACT hContact, LPCSTR szModule, HW signed char cBias = db_get_b(hContact, szModule, "Timezone", -100);
if (cBias != -100) {
int iBias = cBias * 30;
- for (int i = 0; i < g_timezonesBias.getCount(); i++) {
- if (iBias == g_timezonesBias[i]->tzi.Bias) {
- iSelection = i + 1;
+ for (auto &it : g_timezonesBias) {
+ if (iBias == it->tzi.Bias) {
+ iSelection = g_timezonesBias.indexOf(&it) + 1;
break;
}
}
@@ -438,11 +439,9 @@ MIR_CORE_DLL(int) TimeZone_PrepareList(MCONTACT hContact, LPCSTR szModule, HWND SendMessage(hWnd, lstMsg->addStr, 0, (LPARAM)TranslateT("<unspecified>"));
- for (int i = 0; i < g_timezonesBias.getCount(); i++) {
- MIM_TIMEZONE *tz = g_timezonesBias[i];
-
- SendMessage(hWnd, lstMsg->addStr, 0, (LPARAM)tz->szDisplay);
- SendMessage(hWnd, lstMsg->setData, i + 1, (LPARAM)tz);
+ for (auto &it : g_timezonesBias) {
+ SendMessage(hWnd, lstMsg->addStr, 0, (LPARAM)it->szDisplay);
+ SendMessage(hWnd, lstMsg->setData, g_timezonesBias.indexOf(&it) + 1, (LPARAM)it);
}
return TimeZone_SelectListItem(hContact, szModule, hWnd, dwFlags);
|