summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-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]);
}
}