summaryrefslogtreecommitdiff
path: root/protocols/SkypeWeb/src/skype_contacts.cpp
diff options
context:
space:
mode:
authorAlexander Lantsev <aunsane@gmail.com>2015-04-09 20:04:12 +0000
committerAlexander Lantsev <aunsane@gmail.com>2015-04-09 20:04:12 +0000
commit84261a1bda35dcdd1a4e56c3a573a169092f7363 (patch)
tree24031582c3cc692e87b2c33edc58862dc0be55e1 /protocols/SkypeWeb/src/skype_contacts.cpp
parent5504428ab29cacbdc8bb7ca704e6108638bf4ecf (diff)
SkypeWeb: attempt to speed up contact lookup
git-svn-id: http://svn.miranda-ng.org/main/trunk@12717 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/SkypeWeb/src/skype_contacts.cpp')
-rw-r--r--protocols/SkypeWeb/src/skype_contacts.cpp25
1 files changed, 18 insertions, 7 deletions
diff --git a/protocols/SkypeWeb/src/skype_contacts.cpp b/protocols/SkypeWeb/src/skype_contacts.cpp
index c33e1c5dca..4e34d1b2e0 100644
--- a/protocols/SkypeWeb/src/skype_contacts.cpp
+++ b/protocols/SkypeWeb/src/skype_contacts.cpp
@@ -43,24 +43,31 @@ MCONTACT CSkypeProto::GetContactFromAuthEvent(MEVENT hEvent)
MCONTACT CSkypeProto::GetContact(const char *skypename)
{
- MCONTACT hContact = NULL;
- for (hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName))
+ std::map<std::string, MCONTACT>::iterator it = contactMap.find(skypename);
+ if (it != contactMap.end())
+ return it->second;
+
+ for (MCONTACT hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName))
{
- ptrA cSkypename(getStringA(hContact, SKYPE_SETTINGS_ID));
- if (mir_strcmpi(skypename, cSkypename) == 0)
- break;
+ std::string cSkypename = ptrA(getStringA(hContact, SKYPE_SETTINGS_ID));
+ if (!contactMap.count(cSkypename))
+ contactMap[cSkypename] = hContact;
+ if (mir_strcmpi(skypename, cSkypename.c_str()) == 0)
+ return hContact;
}
- return hContact;
+ return NULL;
}
MCONTACT CSkypeProto::AddContact(const char *skypename, bool isTemporary)
{
MCONTACT hContact = GetContact(skypename);
- if (!hContact)
+ if (hContact == NULL)
{
hContact = (MCONTACT)CallService(MS_DB_CONTACT_ADD, 0, 0);
CallService(MS_PROTO_ADDTOCONTACT, hContact, (LPARAM)m_szModuleName);
+ contactMap[skypename] = hContact;
+
setString(hContact, SKYPE_SETTINGS_ID, skypename);
DBVARIANT dbv;
@@ -247,5 +254,9 @@ INT_PTR CSkypeProto::OnGrantAuth(WPARAM hContact, LPARAM)
int CSkypeProto::OnContactDeleted(MCONTACT hContact, LPARAM)
{
+ /*ptrA skypename(getStringA(hContact, SKYPE_SETTINGS_ID));
+ std::map<std::string, MCONTACT>::iterator it = contactMap.find((char*)skypename);
+ if (it != contactMap.end())
+ contactMap.erase(it);*/
return 0;
} \ No newline at end of file