summaryrefslogtreecommitdiff
path: root/plugins/Db3x_mmap/src/dbcontacts.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2013-04-10 08:56:53 +0000
committerGeorge Hazan <george.hazan@gmail.com>2013-04-10 08:56:53 +0000
commit28f76deeabfe071bf78f19f438b795ee7f0a10c4 (patch)
treeca252d633d34cb2a4f02cdace9c9bc98efe8ca23 /plugins/Db3x_mmap/src/dbcontacts.cpp
parent548bb3a6a8ed6f0dbc9b88693e513597a3d0141a (diff)
dbx_mmap: protocol cache is used more intensively
git-svn-id: http://svn.miranda-ng.org/main/trunk@4409 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Db3x_mmap/src/dbcontacts.cpp')
-rw-r--r--plugins/Db3x_mmap/src/dbcontacts.cpp33
1 files 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