summaryrefslogtreecommitdiff
path: root/src/modules/clist
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2014-03-11 19:31:45 +0000
committerGeorge Hazan <george.hazan@gmail.com>2014-03-11 19:31:45 +0000
commit29d0fd99991e9deaae5787b4568b407c50630f84 (patch)
tree66ca2181b7b4840de2b7afb1ff4bdd3578a1325c /src/modules/clist
parentbd4c78f20e084ccdd20c05d1420c06969bc44925 (diff)
old nasty perversion with dynamically created lists removed
git-svn-id: http://svn.miranda-ng.org/main/trunk@8562 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src/modules/clist')
-rw-r--r--src/modules/clist/clistmod.cpp2
-rw-r--r--src/modules/clist/clistsettings.cpp44
2 files changed, 14 insertions, 32 deletions
diff --git a/src/modules/clist/clistmod.cpp b/src/modules/clist/clistmod.cpp
index 72a9c21847..fc6c717519 100644
--- a/src/modules/clist/clistmod.cpp
+++ b/src/modules/clist/clistmod.cpp
@@ -38,7 +38,6 @@ INT_PTR InvalidateDisplayName(WPARAM wParam, LPARAM lParam);
int InitGroupServices(void);
void LoadCluiServices();
INT_PTR Docking_IsDocked(WPARAM wParam, LPARAM lParam);
-void InitDisplayNameCache(void);
void FreeDisplayNameCache(void);
int LoadCLUIModule(void);
int InitClistHotKeys(void);
@@ -506,7 +505,6 @@ int LoadContactListModule2(void)
CreateServiceFunction(MS_CLIST_HOTKEYSPROCESSMESSAGE, HotkeysProcessMessageStub);
CreateServiceFunction(MS_CLIST_GETCONTACTICON, GetContactIcon);
- InitDisplayNameCache();
InitCListEvents();
InitGroupServices();
cli.pfnInitTray();
diff --git a/src/modules/clist/clistsettings.cpp b/src/modules/clist/clistsettings.cpp
index 196daf1b51..c17e6e0d24 100644
--- a/src/modules/clist/clistsettings.cpp
+++ b/src/modules/clist/clistsettings.cpp
@@ -25,31 +25,16 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "..\..\core\commonheaders.h"
#include "clc.h"
-SortedList* clistCache = NULL;
-
-static int compareContacts(ClcCacheEntry *p1, ClcCacheEntry *p2)
-{
- return (char*)p1->hContact - (char*)p2->hContact;
-}
-
-void InitDisplayNameCache(void)
-{
- clistCache = List_Create(0, 50);
- clistCache->sortFunc = (FSortFunc)compareContacts;
-}
+static LIST<ClcCacheEntry> clistCache(50, NumericKeySortT);
void FreeDisplayNameCache(void)
{
- if (clistCache != NULL) {
- for (int i=0; i < clistCache->realCount; i++) {
- cli.pfnFreeCacheItem((ClcCacheEntry*)clistCache->items[i]);
- mir_free(clistCache->items[i]);
- }
-
- List_Destroy(clistCache);
- mir_free(clistCache);
- clistCache = NULL;
+ for (int i=0; i < clistCache.getCount(); i++) {
+ cli.pfnFreeCacheItem(clistCache[i]);
+ mir_free(clistCache[i]);
}
+
+ clistCache.destroy();
}
// default handlers for the cache item creation and destruction
@@ -89,14 +74,14 @@ void fnFreeCacheItem(ClcCacheEntry *p)
ClcCacheEntry* fnGetCacheEntry(MCONTACT hContact)
{
ClcCacheEntry *p;
- int idx;
- if (!List_GetIndex(clistCache, &hContact, &idx)) {
+ int idx = clistCache.getIndex((ClcCacheEntry*)&hContact);
+ if (idx == -1) {
if ((p = cli.pfnCreateCacheItem(hContact)) != NULL) {
- List_Insert(clistCache, p, idx);
- cli.pfnInvalidateDisplayNameCacheEntry((MCONTACT)p);
+ clistCache.insert(p);
+ cli.pfnInvalidateDisplayNameCacheEntry(hContact);
}
}
- else p = (ClcCacheEntry*)clistCache->items[idx];
+ else p = clistCache[idx];
cli.pfnCheckCacheItem(p);
return p;
@@ -106,13 +91,12 @@ void fnInvalidateDisplayNameCacheEntry(MCONTACT hContact)
{
if (hContact == INVALID_CONTACT_ID) {
FreeDisplayNameCache();
- InitDisplayNameCache();
SendMessage(cli.hwndContactTree, CLM_AUTOREBUILD, 0, 0);
}
else {
- int idx;
- if (List_GetIndex(clistCache, &hContact, &idx))
- cli.pfnFreeCacheItem((ClcCacheEntry*)clistCache->items[idx]);
+ int idx = clistCache.getIndex((ClcCacheEntry*)&hContact);
+ if (idx != -1)
+ cli.pfnFreeCacheItem(clistCache[idx]);
}
}