diff options
author | George Hazan <george.hazan@gmail.com> | 2012-10-30 20:09:34 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2012-10-30 20:09:34 +0000 |
commit | 0edc13560169b35dc38e2923f0d240531221cd03 (patch) | |
tree | f9612a145ab9a864f188815bfb289a6e74c4431e /src/modules/database/mdatabasecache.cpp | |
parent | cdff820aeb7d935d18fb66027102f69ec96bf92c (diff) |
- contact's base proto is cached now
- settings cache structure had been changed
git-svn-id: http://svn.miranda-ng.org/main/trunk@2119 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src/modules/database/mdatabasecache.cpp')
-rw-r--r-- | src/modules/database/mdatabasecache.cpp | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/src/modules/database/mdatabasecache.cpp b/src/modules/database/mdatabasecache.cpp index abb24dd0fe..04edbc66c2 100644 --- a/src/modules/database/mdatabasecache.cpp +++ b/src/modules/database/mdatabasecache.cpp @@ -25,7 +25,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "database.h"
static int stringCompare(const char* p1, const char* p2)
-{ return strcmp(p1+1, p2+1);
+{ return strcmp(p1, p2);
}
static int compareGlobals(const DBCachedGlobalValue* p1, const DBCachedGlobalValue* p2)
@@ -90,8 +90,8 @@ void MDatabaseCache::FreeCachedContact(HANDLE hContact) char* MDatabaseCache::InsertCachedSetting(const char* szName, int cbLen)
{
char* newValue = (char*)HeapAlloc(m_hCacheHeap, 0, cbLen);
- *newValue = 0;
- strcpy(newValue+1, szName+1);
+ *newValue++ = 0;
+ strcpy(newValue, szName);
m_lSettings.insert(newValue);
return newValue;
}
@@ -99,18 +99,23 @@ char* MDatabaseCache::InsertCachedSetting(const char* szName, int cbLen) char* MDatabaseCache::GetCachedSetting(const char *szModuleName,const char *szSettingName, int moduleNameLen, int settingNameLen)
{
char szFullName[512];
- strcpy(szFullName+1,szModuleName);
- szFullName[moduleNameLen+1] = '/';
- strcpy(szFullName+moduleNameLen+2,szSettingName);
+ const char *szKey;
+ if (szModuleName != NULL) {
+ strcpy(szFullName, szModuleName);
+ szFullName[moduleNameLen] = '/';
+ strcpy(szFullName+moduleNameLen+1,szSettingName);
+ szKey = szFullName;
+ }
+ else szKey = szSettingName;
- if (m_lastSetting && strcmp(szFullName+1, m_lastSetting) == 0)
+ if (m_lastSetting && !strcmp(szKey, m_lastSetting))
return m_lastSetting;
- int index = m_lSettings.getIndex(szFullName);
+ int index = m_lSettings.getIndex((char*)szKey);
if (index != -1)
- m_lastSetting = m_lSettings[index]+1;
+ m_lastSetting = m_lSettings[index];
else
- m_lastSetting = InsertCachedSetting( szFullName, settingNameLen+moduleNameLen+3)+1;
+ m_lastSetting = InsertCachedSetting(szKey, settingNameLen+moduleNameLen+3);
return m_lastSetting;
}
|