From a7e5e613f86963c8bf82248ab044e0ea36e42fbc Mon Sep 17 00:00:00 2001 From: George Hazan Date: Fri, 16 Mar 2018 12:09:30 +0300 Subject: LIST<>::indexOf(T**) - fast index calculation for direct iterators --- plugins/Clist_nicer/src/clistevents.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'plugins/Clist_nicer/src') diff --git a/plugins/Clist_nicer/src/clistevents.cpp b/plugins/Clist_nicer/src/clistevents.cpp index 288d55cdcc..d9856cec30 100644 --- a/plugins/Clist_nicer/src/clistevents.cpp +++ b/plugins/Clist_nicer/src/clistevents.cpp @@ -315,19 +315,19 @@ CListEvent* AddEvent(CLISTEVENT *cle) int RemoveEvent(MCONTACT hContact, MEVENT hDbEvent) { // Find the event that should be removed - int i; - for (i = 0; i < pcli->events->getCount(); i++) { - CListEvent &e = (*pcli->events)[i]; - if (e.hContact == hContact && e.hDbEvent == hDbEvent) + CListEvent *e = nullptr; + for (auto &it : *pcli->events) + if (it->hContact == hContact && it->hDbEvent == hDbEvent) { + e = it; break; - } + } // Event was not found - if (i == pcli->events->getCount()) + if (e == nullptr) return 1; // remove event from the notify menu - int iMenuId = (*pcli->events)[i].menuId; + int iMenuId = e->menuId; if (iMenuId > 0) { MENUITEMINFO mii = { 0 }; mii.cbSize = sizeof(mii); -- cgit v1.2.3