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/mir_core | |
parent | ecbca42677af470d672e66d3f6950af208f8f212 (diff) |
LIST<>::indexOf(T**) - fast index calculation for direct iterators
Diffstat (limited to 'src/mir_core')
-rw-r--r-- | src/mir_core/src/timezones.cpp | 23 |
1 files changed, 11 insertions, 12 deletions
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);
|