From 2ec5040dda86f76532d48302fede21866916954a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20P=C3=B6sel?= Date: Wed, 28 Oct 2015 08:32:01 +0000 Subject: Optimize ME_DB_CONTACT_SETTINGCHANGED functions to not use mir_strcmp() but just strcmp() (and similar methods) It's not needed to user mir_* for checking null pointers when we're comparing const strings with DBCONTACTWRITESETTING values which should be always initialized correctly. Somewhere also changed strcmpi to just strcmp, because these settings are case-sensitive anyway. git-svn-id: http://svn.miranda-ng.org/main/trunk@15631 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- src/core/stdclist/src/clistopts.cpp | 2 +- src/core/stdmsg/src/msgs.cpp | 6 +++--- src/core/stduseronline/src/useronline.cpp | 2 +- src/mir_app/src/DefaultExtraIcons.cpp | 10 +++++----- src/mir_app/src/clc.cpp | 32 +++++++++++++++---------------- src/mir_app/src/clistevents.cpp | 6 +++--- src/mir_app/src/clistsettings.cpp | 16 ++++++++-------- src/mir_app/src/meta_services.cpp | 16 ++++++++-------- 8 files changed, 45 insertions(+), 45 deletions(-) (limited to 'src') diff --git a/src/core/stdclist/src/clistopts.cpp b/src/core/stdclist/src/clistopts.cpp index 8748604ff9..3027e38563 100644 --- a/src/core/stdclist/src/clistopts.cpp +++ b/src/core/stdclist/src/clistopts.cpp @@ -32,7 +32,7 @@ static INT_PTR CALLBACK DlgProcGenOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP MCONTACT hContact = wParam; DBCONTACTWRITESETTING *ws = (DBCONTACTWRITESETTING *)lParam; if (hContact == NULL && ws != NULL && ws->szModule != NULL && ws->szSetting != NULL && - mir_strcmpi(ws->szModule, "CList") == 0 && mir_strcmpi(ws->szSetting, "UseGroups") == 0 && IsWindowVisible(hwndDlg)) { + strcmp(ws->szModule, "CList") == 0 && strcmp(ws->szSetting, "UseGroups") == 0 && IsWindowVisible(hwndDlg)) { CheckDlgButton(hwndDlg, IDC_DISABLEGROUPS, ws->value.bVal == 0 ? BST_CHECKED : BST_UNCHECKED); } } diff --git a/src/core/stdmsg/src/msgs.cpp b/src/core/stdmsg/src/msgs.cpp index 66655cc34f..5840092717 100644 --- a/src/core/stdmsg/src/msgs.cpp +++ b/src/core/stdmsg/src/msgs.cpp @@ -199,14 +199,14 @@ static int MessageSettingChanged(WPARAM hContact, LPARAM lParam) if (cws->szModule == NULL) return 0; - if (!mir_strcmp(cws->szModule, "CList")) + if (!strcmp(cws->szModule, "CList")) WindowList_Broadcast(g_dat.hMessageWindowList, DM_UPDATETITLE, (WPARAM)cws, 0); else if (hContact) { - if (cws->szSetting && !mir_strcmp(cws->szSetting, "Timezone")) + if (cws->szSetting && !strcmp(cws->szSetting, "Timezone")) WindowList_Broadcast(g_dat.hMessageWindowList, DM_NEWTIMEZONE, (WPARAM)cws, 0); else { char *szProto = GetContactProto(hContact); - if (szProto && !mir_strcmp(cws->szModule, szProto)) + if (szProto && !strcmp(cws->szModule, szProto)) WindowList_Broadcast(g_dat.hMessageWindowList, DM_UPDATETITLE, (WPARAM)cws, 0); } } diff --git a/src/core/stduseronline/src/useronline.cpp b/src/core/stduseronline/src/useronline.cpp index dc6a5e682b..fe30974a67 100644 --- a/src/core/stduseronline/src/useronline.cpp +++ b/src/core/stduseronline/src/useronline.cpp @@ -34,7 +34,7 @@ static bool Proto_IsAccountEnabled(PROTOACCOUNT *pa) static int UserOnlineSettingChanged(WPARAM hContact, LPARAM lParam) { DBCONTACTWRITESETTING *cws = (DBCONTACTWRITESETTING*)lParam; - if (hContact == NULL || mir_strcmp(cws->szSetting, "Status")) + if (hContact == NULL || strcmp(cws->szSetting, "Status")) return 0; int newStatus = cws->value.wVal; diff --git a/src/mir_app/src/DefaultExtraIcons.cpp b/src/mir_app/src/DefaultExtraIcons.cpp index ece76bf24c..43024c0552 100644 --- a/src/mir_app/src/DefaultExtraIcons.cpp +++ b/src/mir_app/src/DefaultExtraIcons.cpp @@ -169,13 +169,13 @@ static int SettingChanged(WPARAM hContact, LPARAM lParam) return 0; DBCONTACTWRITESETTING *cws = (DBCONTACTWRITESETTING*)lParam; - bool isProto = (mir_strcmp(cws->szModule, proto) == 0); - if (isProto && mir_strcmp(cws->szSetting, "ApparentMode") == 0) { + bool isProto = (strcmp(cws->szModule, proto) == 0); + if (isProto && strcmp(cws->szSetting, "ApparentMode") == 0) { SetVisibility(hContact, cws->value.type == DBVT_DELETED ? 0 : cws->value.wVal, true); return 0; } - if (mir_strcmp(cws->szSetting, "Gender") == 0 && (isProto || mir_strcmp(cws->szModule, "UserInfo") == 0)) { + if (strcmp(cws->szSetting, "Gender") == 0 && (isProto || strcmp(cws->szModule, "UserInfo") == 0)) { SetGender(hContact, cws->value.type == DBVT_DELETED ? 0 : cws->value.bVal, true); return 0; } @@ -188,9 +188,9 @@ static int SettingChanged(WPARAM hContact, LPARAM lParam) break; if (p.db[j] == NULL && !isProto) continue; - if (p.db[j] != NULL && mir_strcmp(cws->szModule, p.db[j])) + if (p.db[j] != NULL && strcmp(cws->szModule, p.db[j])) continue; - if (mir_strcmp(cws->szSetting, p.db[j + 1])) + if (strcmp(cws->szSetting, p.db[j + 1])) continue; bool show = (cws->value.type != DBVT_DELETED && !IsEmpty(cws->value.pszVal)); diff --git a/src/mir_app/src/clc.cpp b/src/mir_app/src/clc.cpp index cdd39e3e8c..ca55ff61ed 100644 --- a/src/mir_app/src/clc.cpp +++ b/src/mir_app/src/clc.cpp @@ -66,49 +66,49 @@ static int ClcSettingChanged(WPARAM hContact, LPARAM lParam) { DBCONTACTWRITESETTING *cws = (DBCONTACTWRITESETTING *) lParam; if (hContact == NULL) { - if (!mir_strcmp(cws->szModule, "CListGroups")) + if (!strcmp(cws->szModule, "CListGroups")) cli.pfnClcBroadcast(INTM_GROUPSCHANGED, hContact, lParam); return 0; } - if (!mir_strcmp(cws->szModule, "CList")) { - if (!mir_strcmp(cws->szSetting, "MyHandle")) { + if (!strcmp(cws->szModule, "CList")) { + if (!strcmp(cws->szSetting, "MyHandle")) { cli.pfnInvalidateDisplayNameCacheEntry(hContact); cli.pfnClcBroadcast(INTM_NAMECHANGED, hContact, lParam); } - else if (!mir_strcmp(cws->szSetting, "Group")) + else if (!strcmp(cws->szSetting, "Group")) cli.pfnClcBroadcast(INTM_GROUPCHANGED, hContact, lParam); - else if (!mir_strcmp(cws->szSetting, "Hidden")) + else if (!strcmp(cws->szSetting, "Hidden")) cli.pfnClcBroadcast(INTM_HIDDENCHANGED, hContact, lParam); - else if (!mir_strcmp(cws->szSetting, "NotOnList")) + else if (!strcmp(cws->szSetting, "NotOnList")) cli.pfnClcBroadcast(INTM_NOTONLISTCHANGED, hContact, lParam); - else if (!mir_strcmp(cws->szSetting, "Status")) + else if (!strcmp(cws->szSetting, "Status")) cli.pfnClcBroadcast(INTM_INVALIDATE, 0, 0); - else if (!mir_strcmp(cws->szSetting, "NameOrder")) + else if (!strcmp(cws->szSetting, "NameOrder")) cli.pfnClcBroadcast(INTM_NAMEORDERCHANGED, 0, 0); } else { char *szProto = GetContactProto(hContact); if (szProto != NULL) { - if (!mir_strcmp(cws->szModule, "Protocol") && !mir_strcmp(cws->szSetting, "p")) + if (!strcmp(cws->szModule, "Protocol") && !strcmp(cws->szSetting, "p")) cli.pfnClcBroadcast(INTM_PROTOCHANGED, hContact, lParam); // something is being written to a protocol module - if (!mir_strcmp(szProto, cws->szModule)) { + if (!strcmp(szProto, cws->szModule)) { // was a unique setting key written? char *id = (char *) CallProtoServiceInt(NULL,szProto, PS_GETCAPS, PFLAG_UNIQUEIDSETTING, 0); - if ((INT_PTR)id != CALLSERVICE_NOTFOUND && id != NULL && !mir_strcmp(id, cws->szSetting)) + if ((INT_PTR)id != CALLSERVICE_NOTFOUND && id != NULL && !strcmp(id, cws->szSetting)) cli.pfnClcBroadcast(INTM_PROTOCHANGED, hContact, lParam); } } - if (szProto == NULL || mir_strcmp(szProto, cws->szModule)) + if (szProto == NULL || strcmp(szProto, cws->szModule)) return 0; - if (!mir_strcmp(cws->szSetting, "Nick") || !mir_strcmp(cws->szSetting, "FirstName") || !mir_strcmp(cws->szSetting, "e-mail") - || !mir_strcmp(cws->szSetting, "LastName") || !mir_strcmp(cws->szSetting, "UIN")) + if (!strcmp(cws->szSetting, "Nick") || !strcmp(cws->szSetting, "FirstName") || !strcmp(cws->szSetting, "e-mail") + || !strcmp(cws->szSetting, "LastName") || !strcmp(cws->szSetting, "UIN")) cli.pfnClcBroadcast(INTM_NAMECHANGED, hContact, lParam); - else if (!mir_strcmp(cws->szSetting, "ApparentMode")) + else if (!strcmp(cws->szSetting, "ApparentMode")) cli.pfnClcBroadcast(INTM_APPARENTMODECHANGED, hContact, lParam); - else if (!mir_strcmp(cws->szSetting, "IdleTS")) + else if (!strcmp(cws->szSetting, "IdleTS")) cli.pfnClcBroadcast(INTM_IDLECHANGED, hContact, lParam); } return 0; diff --git a/src/mir_app/src/clistevents.cpp b/src/mir_app/src/clistevents.cpp index c57e0642e6..af2a581041 100644 --- a/src/mir_app/src/clistevents.cpp +++ b/src/mir_app/src/clistevents.cpp @@ -365,10 +365,10 @@ static int RemoveEventsForContact(WPARAM wParam, LPARAM) static int CListEventSettingsChanged(WPARAM hContact, LPARAM lParam) { DBCONTACTWRITESETTING *cws = (DBCONTACTWRITESETTING*)lParam; - if (hContact == NULL && cws && cws->szModule && cws->szSetting && mir_strcmp(cws->szModule, "CList") == 0) { - if (mir_strcmp(cws->szSetting, "DisableTrayFlash") == 0) + if (hContact == NULL && cws && cws->szModule && cws->szSetting && strcmp(cws->szModule, "CList") == 0) { + if (strcmp(cws->szSetting, "DisableTrayFlash") == 0) disableTrayFlash = (int)cws->value.bVal; - else if (mir_strcmp(cws->szSetting, "NoIconBlink") == 0) + else if (strcmp(cws->szSetting, "NoIconBlink") == 0) disableIconFlash = (int)cws->value.bVal; } return 0; diff --git a/src/mir_app/src/clistsettings.cpp b/src/mir_app/src/clistsettings.cpp index 050c67a9a3..2c0780aaa7 100644 --- a/src/mir_app/src/clistsettings.cpp +++ b/src/mir_app/src/clistsettings.cpp @@ -172,12 +172,12 @@ int ContactSettingChanged(WPARAM hContact, LPARAM lParam) if (!db_get(hContact, "Protocol", "p", &dbv)) { if (!mir_strcmp(cws->szModule, dbv.pszVal)) { cli.pfnInvalidateDisplayNameCacheEntry(hContact); - if (!mir_strcmp(cws->szSetting, "UIN") || !mir_strcmp(cws->szSetting, "Nick") || !mir_strcmp(cws->szSetting, "FirstName") - || !mir_strcmp(cws->szSetting, "LastName") || !mir_strcmp(cws->szSetting, "e-mail")) + if (!strcmp(cws->szSetting, "UIN") || !strcmp(cws->szSetting, "Nick") || !strcmp(cws->szSetting, "FirstName") + || !strcmp(cws->szSetting, "LastName") || !strcmp(cws->szSetting, "e-mail")) { CallService(MS_CLUI_CONTACTRENAMED, hContact, 0); } - else if (!mir_strcmp(cws->szSetting, "Status")) { + else if (!strcmp(cws->szSetting, "Status")) { if (!db_get_b(hContact, "CList", "Hidden", 0)) { if (db_get_b(NULL, "CList", "HideOffline", SETTING_HIDEOFFLINE_DEFAULT)) { // User's state is changing, and we are hideOffline-ing @@ -200,8 +200,8 @@ int ContactSettingChanged(WPARAM hContact, LPARAM lParam) } } - if (!mir_strcmp(cws->szModule, "CList")) { - if (!mir_strcmp(cws->szSetting, "Hidden")) { + if (!strcmp(cws->szModule, "CList")) { + if (!strcmp(cws->szSetting, "Hidden")) { if (cws->value.type == DBVT_DELETED || cws->value.bVal == 0) { char *szProto = GetContactProto(hContact); cli.pfnChangeContactIcon(hContact, cli.pfnIconFromStatusMode(szProto, szProto == NULL ? ID_STATUS_OFFLINE : db_get_w(hContact, szProto, "Status", ID_STATUS_OFFLINE), hContact), 1); @@ -209,12 +209,12 @@ int ContactSettingChanged(WPARAM hContact, LPARAM lParam) else CallService(MS_CLUI_CONTACTDELETED, hContact, 0); } - if (!mir_strcmp(cws->szSetting, "MyHandle")) + if (!strcmp(cws->szSetting, "MyHandle")) cli.pfnInvalidateDisplayNameCacheEntry(hContact); } - if (!mir_strcmp(cws->szModule, "Protocol")) { - if (!mir_strcmp(cws->szSetting, "p")) { + if (!strcmp(cws->szModule, "Protocol")) { + if (!strcmp(cws->szSetting, "p")) { char *szProto; if (cws->value.type == DBVT_DELETED) szProto = NULL; diff --git a/src/mir_app/src/meta_services.cpp b/src/mir_app/src/meta_services.cpp index d66a1334ca..2965ca635f 100644 --- a/src/mir_app/src/meta_services.cpp +++ b/src/mir_app/src/meta_services.cpp @@ -344,19 +344,19 @@ int Meta_SettingChanged(WPARAM hContact, LPARAM lParam) if (contact_number == -1) return 0; // exit - db corruption - if (!mir_strcmp(dcws->szSetting, "IP")) { + if (!strcmp(dcws->szSetting, "IP")) { if (dcws->value.type == DBVT_DWORD) db_set_dw(ccMeta->contactID, META_PROTO, "IP", dcws->value.dVal); else db_unset(ccMeta->contactID, META_PROTO, "IP"); } - else if (!mir_strcmp(dcws->szSetting, "RealIP")) { + else if (!strcmp(dcws->szSetting, "RealIP")) { if (dcws->value.type == DBVT_DWORD) db_set_dw(ccMeta->contactID, META_PROTO, "RealIP", dcws->value.dVal); else db_unset(ccMeta->contactID, META_PROTO, "RealIP"); } - else if (!mir_strcmp(dcws->szSetting, "ListeningTo")) { + else if (!strcmp(dcws->szSetting, "ListeningTo")) { switch (dcws->value.type) { case DBVT_ASCIIZ: db_set_s(ccMeta->contactID, META_PROTO, "ListeningTo", dcws->value.pszVal); @@ -372,7 +372,7 @@ int Meta_SettingChanged(WPARAM hContact, LPARAM lParam) break; } } - else if (!mir_strcmp(dcws->szSetting, "Nick") && dcws->value.type != DBVT_DELETED) { + else if (!strcmp(dcws->szSetting, "Nick") && dcws->value.type != DBVT_DELETED) { // subcontact nick has changed - update metacontact mir_snprintf(buffer, "Nick%d", contact_number); db_set(ccMeta->contactID, META_PROTO, buffer, &dcws->value); @@ -387,19 +387,19 @@ int Meta_SettingChanged(WPARAM hContact, LPARAM lParam) MCONTACT hMostOnline = Meta_GetMostOnline(ccMeta); Meta_CopyContactNick(ccMeta, hMostOnline); } - else if (!mir_strcmp(dcws->szSetting, "IdleTS")) { + else if (!strcmp(dcws->szSetting, "IdleTS")) { if (dcws->value.type == DBVT_DWORD) db_set_dw(ccMeta->contactID, META_PROTO, "IdleTS", dcws->value.dVal); else if (dcws->value.type == DBVT_DELETED) db_set_dw(ccMeta->contactID, META_PROTO, "IdleTS", 0); } - else if (!mir_strcmp(dcws->szSetting, "LogonTS")) { + else if (!strcmp(dcws->szSetting, "LogonTS")) { if (dcws->value.type == DBVT_DWORD) db_set_dw(ccMeta->contactID, META_PROTO, "LogonTS", dcws->value.dVal); else if (dcws->value.type == DBVT_DELETED) db_set_dw(ccMeta->contactID, META_PROTO, "LogonTS", 0); } - else if (!mir_strcmp(dcws->szModule, "CList") && !mir_strcmp(dcws->szSetting, "MyHandle")) { + else if (!strcmp(dcws->szModule, "CList") && !strcmp(dcws->szSetting, "MyHandle")) { if (dcws->value.type == DBVT_DELETED) { char *proto = GetContactProto(hContact); mir_snprintf(buffer, "CListName%d", contact_number); @@ -421,7 +421,7 @@ int Meta_SettingChanged(WPARAM hContact, LPARAM lParam) Meta_CopyContactNick(ccMeta, Meta_GetMostOnline(ccMeta)); } // subcontact changing status - else if (!mir_strcmp(dcws->szSetting, "Status") && dcws->value.type != DBVT_DELETED) { + else if (!strcmp(dcws->szSetting, "Status") && dcws->value.type != DBVT_DELETED) { // update subcontact status setting mir_snprintf(buffer, "Status%d", contact_number); db_set_w(ccMeta->contactID, META_PROTO, buffer, dcws->value.wVal); -- cgit v1.2.3