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_modern/src/modern_clistevents.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'plugins/Clist_modern/src') diff --git a/plugins/Clist_modern/src/modern_clistevents.cpp b/plugins/Clist_modern/src/modern_clistevents.cpp index 0caf90b0d7..a336f326f9 100644 --- a/plugins/Clist_modern/src/modern_clistevents.cpp +++ b/plugins/Clist_modern/src/modern_clistevents.cpp @@ -158,19 +158,19 @@ CListEvent* cli_AddEvent(CLISTEVENT *cle) int cli_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 *pEvent = nullptr; + for (auto &it : *pcli->events) + if (it->hContact == hContact && it->hDbEvent == hDbEvent) { + pEvent = it; break; - } + } // Event was not found - if (i == pcli->events->getCount()) + if (pEvent == nullptr) return 1; // remove event from the notify menu - int iMenuId = (*pcli->events)[i].menuId; + int iMenuId = pEvent->menuId; if (iMenuId > 0) { MENUITEMINFO mii = { 0 }; mii.cbSize = sizeof(mii); -- cgit v1.2.3