From f4ab8d1b8466efaed401a75a1d181fc45ff43d5e Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 2 Jan 2014 17:24:17 +0000 Subject: minus std::string & 3 std::vectors git-svn-id: http://svn.miranda-ng.org/main/trunk@7461 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- src/modules/extraicons/extraicons.cpp | 64 +++++++++++++++++------------------ 1 file changed, 31 insertions(+), 33 deletions(-) (limited to 'src/modules/extraicons/extraicons.cpp') diff --git a/src/modules/extraicons/extraicons.cpp b/src/modules/extraicons/extraicons.cpp index 332d6f92f4..c96dd3629f 100644 --- a/src/modules/extraicons/extraicons.cpp +++ b/src/modules/extraicons/extraicons.cpp @@ -128,10 +128,10 @@ BaseExtraIcon* GetExtraIconByName(const char *name) return NULL; } -static void LoadGroups(vector &groups) +static void LoadGroups(LIST &groups) { - unsigned int count = db_get_w(NULL, MODULE_NAME "Groups", "Count", 0); - for (unsigned int i = 0; i < count; i++) { + int count = db_get_w(NULL, MODULE_NAME "Groups", "Count", 0); + for (int i=0; i < count; i++) { char setting[512]; mir_snprintf(setting, SIZEOF(setting), "%d_count", i); unsigned int items = db_get_w(NULL, MODULE_NAME "Groups", setting, 0); @@ -143,36 +143,33 @@ static void LoadGroups(vector &groups) for (unsigned int j = 0; j < items; j++) { mir_snprintf(setting, SIZEOF(setting), "%d_%d", i, j); + ptrA szIconName(db_get_sa(NULL, MODULE_NAME "Groups", setting)); + if (IsEmpty(szIconName)) + continue; + + BaseExtraIcon *extra = GetExtraIconByName(szIconName); + if (extra == NULL) + continue; - DBVARIANT dbv; - if (!db_get_s(NULL, MODULE_NAME "Groups", setting, &dbv)) { - if (!IsEmpty(dbv.pszVal)) { - BaseExtraIcon *extra = GetExtraIconByName(dbv.pszVal); - if (extra != NULL) { - group->items.push_back(extra); - - if (extra->getSlot() >= 0) - group->setSlot(extra->getSlot()); - } - } - db_free(&dbv); - } + group->items.insert(extra); + if (extra->getSlot() >= 0) + group->setSlot(extra->getSlot()); } - if (group->items.size() < 2) { + if (group->items.getCount() < 2) { delete group; continue; } - groups.push_back(group); + groups.insert(group); } } -static ExtraIconGroup* IsInGroup(vector &groups, BaseExtraIcon *extra) +static ExtraIconGroup* IsInGroup(LIST &groups, BaseExtraIcon *extra) { - for (unsigned int i = 0; i < groups.size(); i++) { + for (int i = 0; i < groups.getCount(); i++) { ExtraIconGroup *group = groups[i]; - for (unsigned int j = 0; j < group->items.size(); j++) { + for (int j = 0; j < group->items.getCount(); j++) { if (extra == group->items[j]) return group; } @@ -180,31 +177,30 @@ static ExtraIconGroup* IsInGroup(vector &groups, BaseExtraIcon return NULL; } -void RebuildListsBasedOnGroups(vector &groups) +void RebuildListsBasedOnGroups(LIST &groups) { extraIconsByHandle.destroy(); - int k; - for (k=0; k < registeredExtraIcons.getCount(); k++) - extraIconsByHandle.insert(registeredExtraIcons[k]); - for (k=0; k < extraIconsBySlot.getCount(); k++) { + for (int i=0; i < registeredExtraIcons.getCount(); i++) + extraIconsByHandle.insert(registeredExtraIcons[i]); + + for (int k=0; k < extraIconsBySlot.getCount(); k++) { ExtraIcon *extra = extraIconsBySlot[k]; if (extra->getType() == EXTRAICON_TYPE_GROUP) delete extra; } extraIconsBySlot.destroy(); - unsigned int i; - for (i = 0; i < groups.size(); i++) { + for (int i=0; i < groups.getCount(); i++) { ExtraIconGroup *group = groups[i]; - for (unsigned int j = 0; j < group->items.size(); j++) + for (int j = 0; j < group->items.getCount(); j++) extraIconsByHandle.put(group->items[j]->getID()-1, group); extraIconsBySlot.insert(group); } - for (k = 0; k < extraIconsByHandle.getCount(); k++) { + for (int k=0; k < extraIconsByHandle.getCount(); k++) { ExtraIcon *extra = extraIconsByHandle[k]; if (extra->getType() != EXTRAICON_TYPE_GROUP) extraIconsBySlot.insert(extra); @@ -228,9 +224,10 @@ void KillModuleExtraIcons(int hLangpack) if (arDeleted.getCount() == 0) return; - vector groups; + LIST groups(1); LoadGroups(groups); RebuildListsBasedOnGroups(groups); + groups.destroy(); for (int k=0; k < arDeleted.getCount(); k++) delete arDeleted[k]; @@ -429,14 +426,14 @@ INT_PTR ExtraIcon_Register(WPARAM wParam, LPARAM lParam) registeredExtraIcons.insert(extra); extraIconsByHandle.insert(extra); - vector groups; + LIST groups(1); LoadGroups(groups); ExtraIconGroup *group = IsInGroup(groups, extra); if (group != NULL) RebuildListsBasedOnGroups(groups); else { - for (unsigned int i = 0; i < groups.size(); i++) + for (int i = 0; i < groups.getCount(); i++) delete groups[i]; extraIconsBySlot.insert(extra); @@ -460,6 +457,7 @@ INT_PTR ExtraIcon_Register(WPARAM wParam, LPARAM lParam) } } + groups.destroy(); return id; } -- cgit v1.2.3