From dad59528ccd770301b29c7db8148ff8ab8e89c92 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 14 Mar 2018 19:59:06 +0300 Subject: reverse iterators for LIST<> --- plugins/FavContacts/src/contact_cache.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'plugins/FavContacts/src') diff --git a/plugins/FavContacts/src/contact_cache.cpp b/plugins/FavContacts/src/contact_cache.cpp index d60cd00d84..5ebd3f1c71 100644 --- a/plugins/FavContacts/src/contact_cache.cpp +++ b/plugins/FavContacts/src/contact_cache.cpp @@ -38,13 +38,12 @@ int __cdecl CContactCache::OnDbEventAdded(WPARAM hContact, LPARAM hEvent) TContactInfo *pFound = nullptr; mir_cslock lck(m_cs); - for (int i = m_cache.getCount()-1; i >= 0; i--) { - TContactInfo *p = m_cache[i]; - p->rate *= q; - if (p->hContact == hContact) { - p->rate += weight; - pFound = p; - m_cache.remove(i); // reinsert to maintain the sort order + for (auto &it : m_cache.rev_iter()) { + it->rate *= q; + if (it->hContact == hContact) { + it->rate += weight; + pFound = it; + m_cache.remove(it); // reinsert to maintain the sort order } } -- cgit v1.2.3