From 44b60862c97e5ec855d2bacd4d15f81f7ae7f410 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 15 Mar 2018 15:33:54 +0300 Subject: MUCH more effective way of removing records from iterators --- plugins/FavContacts/src/contact_cache.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'plugins/FavContacts/src') diff --git a/plugins/FavContacts/src/contact_cache.cpp b/plugins/FavContacts/src/contact_cache.cpp index 5ebd3f1c71..6cf3b37761 100644 --- a/plugins/FavContacts/src/contact_cache.cpp +++ b/plugins/FavContacts/src/contact_cache.cpp @@ -38,12 +38,13 @@ int __cdecl CContactCache::OnDbEventAdded(WPARAM hContact, LPARAM hEvent) TContactInfo *pFound = nullptr; mir_cslock lck(m_cs); - for (auto &it : m_cache.rev_iter()) { + auto T = m_cache.rev_iter(); + for (auto &it : T) { it->rate *= q; if (it->hContact == hContact) { it->rate += weight; pFound = it; - m_cache.remove(it); // reinsert to maintain the sort order + m_cache.remove(T.indexOf(&it)); // reinsert to maintain the sort order } } -- cgit v1.2.3