diff options
author | George Hazan <ghazan@miranda.im> | 2018-01-26 22:31:20 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2018-01-26 22:31:27 +0300 |
commit | 391980ce1e890445542441eeb5d9f9cc18ae1baf (patch) | |
tree | ee1b165175dcdaeeaabd2ddb822542e648663a90 /plugins/MenuItemEx | |
parent | bf8ad124d03b4fd059318d9ba8889b11faaf5b53 (diff) |
code optimization
Diffstat (limited to 'plugins/MenuItemEx')
-rw-r--r-- | plugins/MenuItemEx/src/main.cpp | 24 | ||||
-rw-r--r-- | plugins/MenuItemEx/src/options.cpp | 20 |
2 files changed, 19 insertions, 25 deletions
diff --git a/plugins/MenuItemEx/src/main.cpp b/plugins/MenuItemEx/src/main.cpp index e77177358f..f6238d5cfb 100644 --- a/plugins/MenuItemEx/src/main.cpp +++ b/plugins/MenuItemEx/src/main.cpp @@ -289,16 +289,16 @@ int StatusMsgExists(MCONTACT hContact) LPSTR module = GetContactProto(hContact);
if (!module) return 0;
- for (int i = 0; i < _countof(statusMsg); i++) {
- if (statusMsg[i].flag & 8)
- mir_snprintf(par, "%s/%s", module, statusMsg[i].name);
+ for (auto &it : statusMsg) {
+ if (it.flag & 8)
+ mir_snprintf(par, "%s/%s", module, it.name);
else
- strncpy(par, statusMsg[i].name, _countof(par)-1);
+ strncpy(par, it.name, _countof(par)-1);
- LPSTR msg = db_get_sa(hContact, (statusMsg[i].module) ? statusMsg[i].module : module, par);
+ LPSTR msg = db_get_sa(hContact, (it.module) ? it.module : module, par);
if (msg) {
if (mir_strlen(msg))
- ret |= statusMsg[i].flag;
+ ret |= it.flag;
mir_free(msg);
}
}
@@ -609,17 +609,17 @@ static INT_PTR onCopyStatusMsg(WPARAM wparam, LPARAM lparam) return 0;
buffer[0] = 0;
- for (int i = 0; i < _countof(statusMsg); i++) {
- if (statusMsg[i].flag & 8)
- mir_snprintf(par, "%s/%s", module, statusMsg[i].name);
+ for (auto &it : statusMsg) {
+ if (it.flag & 8)
+ mir_snprintf(par, "%s/%s", module, it.name);
else
- strncpy(par, statusMsg[i].name, _countof(par) - 1);
+ strncpy(par, it.name, _countof(par) - 1);
- LPTSTR msg = db_get_wsa(hContact, (statusMsg[i].module) ? statusMsg[i].module : module, par);
+ LPTSTR msg = db_get_wsa(hContact, (it.module) ? it.module : module, par);
if (msg) {
if (wcslen(msg)) {
if (flags & VF_SMNAME) {
- mir_wstrncat(buffer, TranslateW(statusMsg[i].fullName), (_countof(buffer) - wcslen(buffer) - 1));
+ mir_wstrncat(buffer, TranslateW(it.fullName), (_countof(buffer) - wcslen(buffer) - 1));
mir_wstrncat(buffer, L": ", (_countof(buffer) - wcslen(buffer) - 1));
}
mir_wstrncat(buffer, msg, (_countof(buffer) - wcslen(buffer) - 1));
diff --git a/plugins/MenuItemEx/src/options.cpp b/plugins/MenuItemEx/src/options.cpp index 997bc2d417..853fdb40d8 100644 --- a/plugins/MenuItemEx/src/options.cpp +++ b/plugins/MenuItemEx/src/options.cpp @@ -35,25 +35,19 @@ INT_PTR CALLBACK OptionsProc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lparam) switch (msg) {
case WM_INITDIALOG:
-
TranslateDialogDefault(hdlg);
- for (i = 0; i < _countof(checkboxes); i++)
- {
- CheckDlgButton(hdlg, checkboxes[i].idc, (flags & checkboxes[i].flag) ? BST_CHECKED : BST_UNCHECKED);
- }
+ for (auto &it : checkboxes)
+ CheckDlgButton(hdlg, it.idc, (flags & it.flag) ? BST_CHECKED : BST_UNCHECKED);
- if (bPopupService)
- {
- for (i = 0; i < 4; i++)
- {
+ if (bPopupService) {
+ for (i = 0; i < 4; i++) {
GetDlgItemText(hdlg, checkboxes[i].idc, buffer, (_countof(buffer) - 3));
mir_wstrcat(buffer, L" *");
SetDlgItemText(hdlg, checkboxes[i].idc, buffer);
}
}
- else
- ShowWindow(GetDlgItem(hdlg, IDC_HINT1), SW_HIDE);
+ else ShowWindow(GetDlgItem(hdlg, IDC_HINT1), SW_HIDE);
SendMessage(hdlg, WM_USER + 50, 0, 0);
return 0;
@@ -72,8 +66,8 @@ INT_PTR CALLBACK OptionsProc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lparam) case PSN_APPLY:
DWORD mod_flags = 0;
- for (i = 0; i < _countof(checkboxes); i++)
- mod_flags |= IsDlgButtonChecked(hdlg, checkboxes[i].idc) ? checkboxes[i].flag : 0;
+ for (auto &it : checkboxes)
+ mod_flags |= IsDlgButtonChecked(hdlg, it.idc) ? it.flag : 0;
db_set_dw(NULL, MODULENAME, "flags", mod_flags);
return 1;
|