summaryrefslogtreecommitdiff
path: root/src/mir_app
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2018-01-26 22:31:20 +0300
committerGeorge Hazan <ghazan@miranda.im>2018-01-26 22:31:27 +0300
commit391980ce1e890445542441eeb5d9f9cc18ae1baf (patch)
treeee1b165175dcdaeeaabd2ddb822542e648663a90 /src/mir_app
parentbf8ad124d03b4fd059318d9ba8889b11faaf5b53 (diff)
code optimization
Diffstat (limited to 'src/mir_app')
-rw-r--r--src/mir_app/src/DefaultExtraIcons.cpp11
-rw-r--r--src/mir_app/src/chat_tools.cpp4
-rw-r--r--src/mir_app/src/clistmod.cpp4
-rw-r--r--src/mir_app/src/findadd.cpp4
-rw-r--r--src/mir_app/src/ignore.cpp5
-rw-r--r--src/mir_app/src/netliblog.cpp8
-rw-r--r--src/mir_app/src/newplugins.cpp16
-rw-r--r--src/mir_app/src/proto_accs.cpp4
-rw-r--r--src/mir_app/src/skinicons.cpp6
-rw-r--r--src/mir_app/src/utils.cpp12
-rw-r--r--src/mir_app/src/visibility.cpp8
11 files changed, 39 insertions, 43 deletions
diff --git a/src/mir_app/src/DefaultExtraIcons.cpp b/src/mir_app/src/DefaultExtraIcons.cpp
index f98f44fe11..26e9ae9d1f 100644
--- a/src/mir_app/src/DefaultExtraIcons.cpp
+++ b/src/mir_app/src/DefaultExtraIcons.cpp
@@ -144,9 +144,7 @@ static void SetExtraIcons(MCONTACT hContact)
if ( IsEmpty(proto))
return;
- for (unsigned int i = 0; i < _countof(infos); i++) {
- Info &p = infos[i];
-
+ for (auto &p : infos) {
for (unsigned int j = 0; j < _countof(p.db); j += 2) {
if (p.db[j + 1] == nullptr)
break;
@@ -181,9 +179,7 @@ static int SettingChanged(WPARAM hContact, LPARAM lParam)
return 0;
}
- for (int i = 0; i < _countof(infos); i++) {
- Info &p = infos[i];
-
+ for (auto &p : infos) {
for (int j = 0; j < _countof(p.db); j += 2) {
if (p.db[j + 1] == nullptr)
break;
@@ -308,8 +304,7 @@ void DefaultExtraIcons_Load()
hExtraProto = ExtraIcon_RegisterCallback("protocol", "Account", Skin_GetIconName(SKINICON_OTHER_ACCMGR),
&ProtocolRebuildIcons, &ProtocolApplyIcon, &ProtocolOnClick, 0, EIF_DISABLED_BY_DEFAULT);
- for (int i = 0; i < _countof(infos); i++) {
- Info &p = infos[i];
+ for (auto &p : infos) {
p.hIcolib = Skin_GetIconHandle(p.iSkinIcon);
if (p.OnClick)
p.hExtraIcon = ExtraIcon_RegisterIcolib(p.name, p.desc, Skin_GetIconName(p.iSkinIcon), DefaultOnClick, (LPARAM)&p, p.flags);
diff --git a/src/mir_app/src/chat_tools.cpp b/src/mir_app/src/chat_tools.cpp
index 35e35a0f29..a3240c2ef3 100644
--- a/src/mir_app/src/chat_tools.cpp
+++ b/src/mir_app/src/chat_tools.cpp
@@ -681,8 +681,8 @@ wchar_t* GetChatLogsFilename(SESSION_INFO *si, time_t tTime)
PathToAbsoluteW(tszParsedName, si->pszLogFileName);
mir_free(tszParsedName);
- for (int i = 0; i < _countof(rva); i++)
- mir_free(rva[i].value.w);
+ for (auto &it : rva)
+ mir_free(it.value.w);
for (wchar_t *p = si->pszLogFileName + 2; *p; ++p)
if (*p == ':' || *p == '*' || *p == '?' || *p == '"' || *p == '<' || *p == '>' || *p == '|')
diff --git a/src/mir_app/src/clistmod.cpp b/src/mir_app/src/clistmod.cpp
index 30ffa63b80..2f4c7876a4 100644
--- a/src/mir_app/src/clistmod.cpp
+++ b/src/mir_app/src/clistmod.cpp
@@ -435,8 +435,8 @@ int LoadContactListModule2(void)
ImageList_AddIcon_NotShared(hCListImages, MAKEINTRESOURCE(IDI_BLANK));
// now all core skin icons are loaded via icon lib. so lets release them
- for (int i = 0; i < _countof(statusModeList); i++)
- ImageList_AddIcon_IconLibLoaded(hCListImages, skinIconStatusList[i]);
+ for (auto &it : statusModeList)
+ ImageList_AddIcon_IconLibLoaded(hCListImages, it);
// see IMAGE_GROUP... in clist.h if you add more images above here
ImageList_AddIcon_IconLibLoaded(hCListImages, SKINICON_OTHER_GROUPOPEN);
diff --git a/src/mir_app/src/findadd.cpp b/src/mir_app/src/findadd.cpp
index 58132b95b9..bc1e252a0c 100644
--- a/src/mir_app/src/findadd.cpp
+++ b/src/mir_app/src/findadd.cpp
@@ -284,8 +284,8 @@ static const int controls[] = { IDC_BYPROTOID, IDC_BYEMAIL, IDC_BYNAME, IDC_BYAD
static void CheckSearchTypeRadioButton(HWND hwndDlg, int idControl)
{
- for (int i = 0; i < _countof(controls); i++)
- CheckDlgButton(hwndDlg, controls[i], idControl == controls[i] ? BST_CHECKED : BST_UNCHECKED);
+ for (auto &it : controls)
+ CheckDlgButton(hwndDlg, it, idControl == it ? BST_CHECKED : BST_UNCHECKED);
}
#define sttErrMsg TranslateT("You haven't filled in the search field. Please enter a search term and try again.")
diff --git a/src/mir_app/src/ignore.cpp b/src/mir_app/src/ignore.cpp
index f5dfb0f254..f0c9032a0a 100644
--- a/src/mir_app/src/ignore.cpp
+++ b/src/mir_app/src/ignore.cpp
@@ -314,8 +314,9 @@ static INT_PTR CALLBACK DlgProcIgnoreOpts(HWND hwndDlg, UINT msg, WPARAM, LPARAM
break;
case WM_DESTROY:
- for (int i = 0; i < _countof(hIcons); i++)
- DestroyIcon(hIcons[i]);
+ for (auto &it : hIcons)
+ DestroyIcon(it);
+
HIMAGELIST hIml = (HIMAGELIST)SendDlgItemMessage(hwndDlg, IDC_LIST, CLM_GETEXTRAIMAGELIST, 0, 0);
ImageList_Destroy(hIml);
break;
diff --git a/src/mir_app/src/netliblog.cpp b/src/mir_app/src/netliblog.cpp
index 226da520bf..6bb9fc32a3 100644
--- a/src/mir_app/src/netliblog.cpp
+++ b/src/mir_app/src/netliblog.cpp
@@ -103,10 +103,10 @@ static INT_PTR CALLBACK LogOptionsDlgProc(HWND hwndDlg, UINT message, WPARAM wPa
CheckDlgButton(hwndDlg, IDC_DUMPSSL, logOptions.dumpSsl ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_TEXTDUMPS, logOptions.textDumps ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_AUTODETECTTEXT, logOptions.autoDetectText ? BST_CHECKED : BST_UNCHECKED);
- {
- for (int i=0; i < _countof(szTimeFormats); i++)
- SendDlgItemMessage(hwndDlg, IDC_TIMEFORMAT, CB_ADDSTRING, 0, (LPARAM)TranslateW(szTimeFormats[i]));
- }
+
+ for (auto &it : szTimeFormats)
+ SendDlgItemMessage(hwndDlg, IDC_TIMEFORMAT, CB_ADDSTRING, 0, (LPARAM)TranslateW(it));
+
SendDlgItemMessage(hwndDlg, IDC_TIMEFORMAT, CB_SETCURSEL, logOptions.timeFormat, 0);
CheckDlgButton(hwndDlg, IDC_SHOWNAMES, logOptions.showUser ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_TOOUTPUTDEBUGSTRING, logOptions.toOutputDebugString ? BST_CHECKED : BST_UNCHECKED);
diff --git a/src/mir_app/src/newplugins.cpp b/src/mir_app/src/newplugins.cpp
index 2ab86f710d..f16ba12347 100644
--- a/src/mir_app/src/newplugins.cpp
+++ b/src/mir_app/src/newplugins.cpp
@@ -121,8 +121,8 @@ static const MUUID pluginBannedList[] =
static bool isPluginBanned(const MUUID& u1)
{
- for (int i = 0; i < _countof(pluginBannedList); i++)
- if (pluginBannedList[i] == u1)
+ for (auto &it : pluginBannedList)
+ if (it == u1)
return true;
return false;
@@ -156,11 +156,11 @@ int getDefaultPluginIdx(const MUUID &muuid)
int LoadStdPlugins()
{
- for (int i = 0; i < _countof(pluginDefault); i++) {
- if (pluginDefault[i].pImpl)
+ for (auto &it : pluginDefault) {
+ if (it.pImpl)
continue;
- if (!LoadCorePlugin(pluginDefault[i]))
+ if (!LoadCorePlugin(it))
return 1;
}
@@ -380,9 +380,9 @@ int Plugin_UnloadDyn(pluginEntry *p)
// mark default plugins to be loaded
if (!(p->pclass & PCLASS_CORE))
- for (int i = 0; i < _countof(pluginDefault); i++)
- if (pluginDefault[i].pImpl == p)
- pluginDefault[i].pImpl = nullptr;
+ for (auto &it : pluginDefault)
+ if (it.pImpl == p)
+ it.pImpl = nullptr;
return TRUE;
}
diff --git a/src/mir_app/src/proto_accs.cpp b/src/mir_app/src/proto_accs.cpp
index ef8c5d4e86..269027909d 100644
--- a/src/mir_app/src/proto_accs.cpp
+++ b/src/mir_app/src/proto_accs.cpp
@@ -413,8 +413,8 @@ void UnloadAccountsModule()
}
accounts.destroy();
- for (int i = 0; i < _countof(hHooks); i++)
- UnhookEvent(hHooks[i]);
+ for (auto &it : hHooks)
+ UnhookEvent(it);
}
/////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/mir_app/src/skinicons.cpp b/src/mir_app/src/skinicons.cpp
index c27b8386a0..c54dea3dcd 100644
--- a/src/mir_app/src/skinicons.cpp
+++ b/src/mir_app/src/skinicons.cpp
@@ -341,9 +341,9 @@ MIR_APP_DLL(HICON) Skin_LoadProtoIcon(const char *szProto, int status, bool big)
MIR_APP_DLL(HANDLE) Skin_GetIconHandle(int idx)
{
- for (int i = 0; i < _countof(mainIcons); i++)
- if (idx == mainIcons[i].id)
- return mainIcons[i].hIcolib;
+ for (auto &it : mainIcons)
+ if (idx == it.id)
+ return it.hIcolib;
return nullptr;
}
diff --git a/src/mir_app/src/utils.cpp b/src/mir_app/src/utils.cpp
index 167a397a58..170c7db7c2 100644
--- a/src/mir_app/src/utils.cpp
+++ b/src/mir_app/src/utils.cpp
@@ -292,18 +292,18 @@ static CountryListEntry countries[] = {
static INT_PTR GetCountryByNumber(WPARAM wParam, LPARAM)
{
- for (int i = 0; i < _countof(countries); i++)
- if ((int)wParam == countries[i].id)
- return (INT_PTR)countries[i].szName;
+ for (auto &it : countries)
+ if ((int)wParam == it.id)
+ return (INT_PTR)it.szName;
return 0;
}
static INT_PTR GetCountryByISOCode(WPARAM wParam, LPARAM)
{
- for (int i = 0; i < _countof(countries); i++)
- if ( mir_strcmpi((char*)wParam, countries[i].ISOcode) == 0)
- return (INT_PTR)countries[i].szName;
+ for (auto &it : countries)
+ if ( mir_strcmpi((char*)wParam, it.ISOcode) == 0)
+ return (INT_PTR)it.szName;
return 0;
}
diff --git a/src/mir_app/src/visibility.cpp b/src/mir_app/src/visibility.cpp
index 8abdfabaf5..5946ca3159 100644
--- a/src/mir_app/src/visibility.cpp
+++ b/src/mir_app/src/visibility.cpp
@@ -50,7 +50,7 @@ static void SetListGroupIcons(HWND hwndList, HANDLE hFirstItem, HANDLE hParentIt
else
hItem = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXTCONTACT, (LPARAM)hFirstItem);
while (hItem) {
- for (int i=0; i < _countof(iconOn); i++) {
+ for (int i = 0; i < _countof(iconOn); i++) {
int iImage = SendMessage(hwndList, CLM_GETEXTRAIMAGE, (WPARAM)hItem, i);
if (iconOn[i] && iImage == 0) iconOn[i] = 0;
if (iImage != EMPTY_EXTRA_ICON)
@@ -59,9 +59,9 @@ static void SetListGroupIcons(HWND hwndList, HANDLE hFirstItem, HANDLE hParentIt
hItem = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXTCONTACT, (LPARAM)hItem);
}
//set icons
- for (int i=0; i < _countof(iconOn); i++) {
- SendMessage(hwndList, CLM_SETEXTRAIMAGE, (WPARAM)hParentItem, MAKELPARAM(i, childCount[i]?(iconOn[i]?i+1:0):EMPTY_EXTRA_ICON));
- if (groupChildCount) groupChildCount[i]+=childCount[i];
+ for (int i = 0; i < _countof(iconOn); i++) {
+ SendMessage(hwndList, CLM_SETEXTRAIMAGE, (WPARAM)hParentItem, MAKELPARAM(i, childCount[i] ? (iconOn[i] ? i + 1 : 0) : EMPTY_EXTRA_ICON));
+ if (groupChildCount) groupChildCount[i] += childCount[i];
}
}