diff options
author | George Hazan <george.hazan@gmail.com> | 2025-03-05 14:12:51 +0300 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2025-03-05 14:12:51 +0300 |
commit | f3adc14797ee6889a0134b8f8ebff39436af3a95 (patch) | |
tree | 63f4cc4f90020557991cc4da1eefb0155c27d2e5 /src | |
parent | ad9984bb0faea2bb1fde27413af066c800d76805 (diff) |
speed optimization - double call of db_get removed
Diffstat (limited to 'src')
-rw-r--r-- | src/mir_app/src/contacts.cpp | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/mir_app/src/contacts.cpp b/src/mir_app/src/contacts.cpp index ecfec7475a..250cd71304 100644 --- a/src/mir_app/src/contacts.cpp +++ b/src/mir_app/src/contacts.cpp @@ -41,14 +41,11 @@ uint8_t nameOrder[_countof(nameOrderDescr)]; static wchar_t* ProcessDatabaseValueDefault(MCONTACT hContact, const char *szProto, const char *szSetting)
{
- wchar_t *ret = db_get_wsa(hContact, szProto, szSetting);
- if (ret)
- return ret;
-
DBVARIANT dbv;
if (db_get(hContact, szProto, szSetting, &dbv))
return nullptr;
+ wchar_t *ret;
wchar_t buf[40];
switch (dbv.type) {
case DBVT_BYTE:
@@ -66,6 +63,16 @@ static wchar_t* ProcessDatabaseValueDefault(MCONTACT hContact, const char *szPro else
ret = bin2hexW(dbv.pbVal, min(int(dbv.cpbVal), 19), buf);
break;
+ case DBVT_ASCIIZ:
+ ret = mir_a2u(dbv.pszVal);
+ break;
+ case DBVT_UTF8:
+ ret = mir_utf8decodeW(dbv.pszVal);
+ break;
+ case DBVT_WCHAR:
+ return dbv.pwszVal; // no need to free dbv
+ default:
+ ret = nullptr;
}
db_free(&dbv);
@@ -154,7 +161,7 @@ MIR_APP_DLL(wchar_t*) Contact::GetInfo(int type, MCONTACT hContact, const char * db_free(&dbv2);
return buf;
}
- db_free(&dbv);
+ return dbv.pwszVal;
}
break;
|