summaryrefslogtreecommitdiff
path: root/plugins/FavContacts/src
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2018-03-15 15:33:54 +0300
committerGeorge Hazan <ghazan@miranda.im>2018-03-15 15:34:09 +0300
commit44b60862c97e5ec855d2bacd4d15f81f7ae7f410 (patch)
treecfe6fd232fac8c80c2f7673804352b94187d698b /plugins/FavContacts/src
parent0a03c7c9ccd36ce03bdb9feb4827314e4dd553c6 (diff)
MUCH more effective way of removing records from iterators
Diffstat (limited to 'plugins/FavContacts/src')
-rw-r--r--plugins/FavContacts/src/contact_cache.cpp5
1 files changed, 3 insertions, 2 deletions
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
}
}