diff options
author | Robert Pösel <robyer@seznam.cz> | 2015-10-28 08:32:04 +0000 |
---|---|---|
committer | Robert Pösel <robyer@seznam.cz> | 2015-10-28 08:32:04 +0000 |
commit | 8b53cbae6e56c389c4c72088fa24dc22ec569bf9 (patch) | |
tree | 70d870e82c4987f42eee8ac8cb274661497f577c /plugins/Variables/src/contact.cpp | |
parent | 2ec5040dda86f76532d48302fede21866916954a (diff) |
Variables: Optimize weird insides of contactSettingChanged() function
git-svn-id: http://svn.miranda-ng.org/main/trunk@15632 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Variables/src/contact.cpp')
-rw-r--r-- | plugins/Variables/src/contact.cpp | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/plugins/Variables/src/contact.cpp b/plugins/Variables/src/contact.cpp index a61b0524d0..995a4ce610 100644 --- a/plugins/Variables/src/contact.cpp +++ b/plugins/Variables/src/contact.cpp @@ -359,23 +359,31 @@ static int contactSettingChanged(WPARAM hContact, LPARAM lParam) {
DBCONTACTWRITESETTING *dbw = (DBCONTACTWRITESETTING*)lParam;
+ char *szProto = GetContactProto(hContact);
+ if (szProto == NULL)
+ return 0;
+
+ char *uid = (char*)CallProtoService(szProto, PS_GETCAPS, PFLAG_UNIQUEIDSETTING, 0);
+
+ bool isNick = !strcmp(dbw->szSetting, "Nick");
+ bool isFirstName = !strcmp(dbw->szSetting, "FirstName");
+ bool isLastName = !strcmp(dbw->szSetting, "LastName");
+ bool isEmail = !strcmp(dbw->szSetting, "e-mail");
+ bool isMyHandle = !strcmp(dbw->szSetting, "MyHandle");
+ bool isUid = (((INT_PTR)uid != CALLSERVICE_NOTFOUND) && (uid != NULL)) && (!strcmp(dbw->szSetting, uid));
+
mir_cslock lck(csContactCache);
for (int i = 0; i < cacheSize; i++) {
if (hContact != cce[i].hContact && (cce[i].flags & CI_CNFINFO) == 0)
continue;
-
- char *szProto = GetContactProto(hContact);
- if (szProto == NULL)
- continue;
-
- char *uid = (char*)CallProtoService(szProto, PS_GETCAPS, PFLAG_UNIQUEIDSETTING, 0);
- if (((!strcmp(dbw->szSetting, "Nick")) && (cce[i].flags & CI_NICK)) ||
- ((!strcmp(dbw->szSetting, "FirstName")) && (cce[i].flags & CI_FIRSTNAME)) ||
- ((!strcmp(dbw->szSetting, "LastName")) && (cce[i].flags & CI_LASTNAME)) ||
- ((!strcmp(dbw->szSetting, "e-mail")) && (cce[i].flags & CI_EMAIL)) ||
- ((!strcmp(dbw->szSetting, "MyHandle")) && (cce[i].flags & CI_LISTNAME)) ||
+
+ if ((isNick && (cce[i].flags & CI_NICK)) ||
+ (isFirstName && (cce[i].flags & CI_FIRSTNAME)) ||
+ (isLastName && (cce[i].flags & CI_LASTNAME)) ||
+ (isEmail && (cce[i].flags & CI_EMAIL)) ||
+ (isMyHandle && (cce[i].flags & CI_LISTNAME)) ||
(cce[i].flags & CI_CNFINFO) != 0 || // lazy; always invalidate CNF info cache entries
- ((((INT_PTR)uid != CALLSERVICE_NOTFOUND) && (uid != NULL)) && (!strcmp(dbw->szSetting, uid)) && (cce[i].flags & CI_UNIQUEID))) {
+ (isUid && (cce[i].flags & CI_UNIQUEID))) {
/* remove from cache */
mir_free(cce[i].tszContact);
if (cacheSize > 1) {
|