From 28f76deeabfe071bf78f19f438b795ee7f0a10c4 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 10 Apr 2013 08:56:53 +0000 Subject: dbx_mmap: protocol cache is used more intensively git-svn-id: http://svn.miranda-ng.org/main/trunk@4409 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Db3x_mmap/src/dbcontacts.cpp | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/plugins/Db3x_mmap/src/dbcontacts.cpp b/plugins/Db3x_mmap/src/dbcontacts.cpp index c8be49a189..a5971579e5 100644 --- a/plugins/Db3x_mmap/src/dbcontacts.cpp +++ b/plugins/Db3x_mmap/src/dbcontacts.cpp @@ -25,18 +25,25 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. int CDb3Base::CheckProto(HANDLE hContact, const char *proto) { - char protobuf[MAX_PATH] = {0}; - DBVARIANT dbv; - DBCONTACTGETSETTING sVal = { "Protocol", "p", &dbv }; - - dbv.type = DBVT_ASCIIZ; - dbv.pszVal = protobuf; - dbv.cchVal = sizeof(protobuf); - - if ( GetContactSettingStatic(hContact, &sVal) != 0 || (dbv.type != DBVT_ASCIIZ)) - return 0; + DBCachedContact *cc = m_cache->GetCachedContact(hContact); + if (cc == NULL) + cc = m_cache->AddContactToCache(hContact); + + if (cc->szProto == NULL) { + char protobuf[MAX_PATH] = {0}; + DBVARIANT dbv; + DBCONTACTGETSETTING sVal = { "Protocol", "p", &dbv }; + + dbv.type = DBVT_ASCIIZ; + dbv.pszVal = protobuf; + dbv.cchVal = sizeof(protobuf); + if ( GetContactSettingStatic(hContact, &sVal) != 0 || (dbv.type != DBVT_ASCIIZ)) + return 0; + + cc->szProto = m_cache->GetCachedSetting(NULL, protobuf, 0, (int)strlen(protobuf)); + } - return !strcmp(protobuf, proto); + return !strcmp(cc->szProto, proto); } STDMETHODIMP_(LONG) CDb3Base::GetContactCount(void) @@ -148,10 +155,6 @@ STDMETHODIMP_(LONG) CDb3Base::DeleteContact(HANDLE hContact) } dbcPrev->ofsNext = ofsNext; DBWrite(ofsThis,dbcPrev,sizeof(DBContact)); - - DBCachedContact *VL = m_cache->GetCachedContact((HANDLE)ofsThis); - if (VL) - VL->hNext = (HANDLE)ofsNext; } //delete contact -- cgit v1.2.3