diff options
author | George Hazan <ghazan@miranda.im> | 2018-03-12 15:27:38 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2018-03-12 15:27:38 +0300 |
commit | 1a694bbb3a2c8faf3667a3d3bdec9e79541b4e30 (patch) | |
tree | fc3ad9dd27c4bd9737f317a32e788b3b003cf6dc | |
parent | 381dc58bd23e8466b6304387687c9d3a255f1efb (diff) |
cycle optimization
-rw-r--r-- | src/mir_app/src/clistevents.cpp | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/src/mir_app/src/clistevents.cpp b/src/mir_app/src/clistevents.cpp index b0046fad9a..5f9a566f44 100644 --- a/src/mir_app/src/clistevents.cpp +++ b/src/mir_app/src/clistevents.cpp @@ -38,7 +38,7 @@ static int iconsOn; static int disableTrayFlash;
static int disableIconFlash;
-OBJLIST<CListEvent> g_cliEvents(10);
+OBJLIST<CListEvent> g_cliEvents(10, PtrKeySortT);
int fnGetImlIconIndex(HICON hIcon)
{
@@ -176,28 +176,29 @@ CListEvent* fnAddEvent(CLISTEVENT *cle) int fnRemoveEvent(MCONTACT hContact, MEVENT dbEvent)
{
// Find the event that should be removed
- int i;
- for (i = 0; i < g_cliEvents.getCount(); i++) {
- CListEvent &e = g_cliEvents[i];
- if (e.hContact == hContact && e.hDbEvent == dbEvent)
+ CListEvent *pEvent = nullptr;
+ for (auto &it : g_cliEvents) {
+ if (it->hContact == hContact && it->hDbEvent == dbEvent) {
+ pEvent = it;
break;
+ }
}
// Event was not found
- if (i == g_cliEvents.getCount())
+ if (pEvent == nullptr)
return 1;
// Update contact's icon
char *szProto = GetContactProto(hContact);
- cli.pfnChangeContactIcon(g_cliEvents[i].hContact, cli.pfnGetContactIcon(g_cliEvents[i].hContact));
+ cli.pfnChangeContactIcon(pEvent->hContact, cli.pfnGetContactIcon(pEvent->hContact));
// Free any memory allocated to the event
- g_cliEvents.remove(i);
+ g_cliEvents.remove(pEvent);
// count same protocoled events
int nSameProto = 0;
- char *szEventProto;
for (auto &it : g_cliEvents) {
+ char *szEventProto;
if (it->hContact)
szEventProto = GetContactProto((it->hContact));
else if (it->flags & CLEF_PROTOCOLGLOBAL)
|