diff options
author | George Hazan <ghazan@miranda.im> | 2018-03-15 15:33:54 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2018-03-15 15:34:09 +0300 |
commit | 44b60862c97e5ec855d2bacd4d15f81f7ae7f410 (patch) | |
tree | cfe6fd232fac8c80c2f7673804352b94187d698b /plugins | |
parent | 0a03c7c9ccd36ce03bdb9feb4827314e4dd553c6 (diff) |
MUCH more effective way of removing records from iterators
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/AVS/src/poll.cpp | 5 | ||||
-rw-r--r-- | plugins/Clist_modern/src/modern_aniavatars.cpp | 5 | ||||
-rw-r--r-- | plugins/FavContacts/src/contact_cache.cpp | 5 | ||||
-rw-r--r-- | plugins/HistorySweeperLight/src/historysweeperlight.cpp | 5 | ||||
-rw-r--r-- | plugins/NewXstatusNotify/src/xstatus.cpp | 15 | ||||
-rw-r--r-- | plugins/TabSRMM/src/eventpopups.cpp | 5 | ||||
-rw-r--r-- | plugins/UserInfoEx/src/mir_contactqueue.cpp | 10 |
7 files changed, 30 insertions, 20 deletions
diff --git a/plugins/AVS/src/poll.cpp b/plugins/AVS/src/poll.cpp index 3ba1bf90a0..940d44f184 100644 --- a/plugins/AVS/src/poll.cpp +++ b/plugins/AVS/src/poll.cpp @@ -104,9 +104,10 @@ static void QueueRemove(MCONTACT hContact) {
mir_cslock lck(cs);
- for (auto &it : queue.rev_iter())
+ auto T = queue.rev_iter();
+ for (auto &it : T)
if (it->hContact == hContact)
- queue.remove(it);
+ queue.remove(T.indexOf(&it));
}
// Add an contact to a queue
diff --git a/plugins/Clist_modern/src/modern_aniavatars.cpp b/plugins/Clist_modern/src/modern_aniavatars.cpp index bc72629674..c04448b182 100644 --- a/plugins/Clist_modern/src/modern_aniavatars.cpp +++ b/plugins/Clist_modern/src/modern_aniavatars.cpp @@ -265,10 +265,11 @@ static void _AniAva_ResumePainting() static void _AniAva_ReduceAvatarImages(int startY, int dY, BOOL bDestroyWindow)
{
- for (auto &it : s_Objects.rev_iter()) {
+ auto T = s_Objects.rev_iter();
+ for (auto &it : T) {
int res = SendMessage(it->hWindow, AAM_REMOVEAVATAR, (WPARAM)startY, (LPARAM)dY);
if (res == 0xDEAD && bDestroyWindow)
- s_Objects.remove(it);
+ s_Objects.remove(T.indexOf(&it));
}
}
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
}
}
diff --git a/plugins/HistorySweeperLight/src/historysweeperlight.cpp b/plugins/HistorySweeperLight/src/historysweeperlight.cpp index 65c37b0196..62a6f3b102 100644 --- a/plugins/HistorySweeperLight/src/historysweeperlight.cpp +++ b/plugins/HistorySweeperLight/src/historysweeperlight.cpp @@ -224,9 +224,10 @@ int OnWindowEvent(WPARAM, LPARAM lParam) SweepHistoryFromContact(msgEvData->hContact, Criteria, TRUE);
}
- for (auto &it : g_hWindows.rev_iter())
+ auto T = g_hWindows.rev_iter();
+ for (auto &it : T)
if (it == PVOID(msgEvData->hContact))
- g_hWindows.remove(it);
+ g_hWindows.remove(T.indexOf(&it));
break;
}
diff --git a/plugins/NewXstatusNotify/src/xstatus.cpp b/plugins/NewXstatusNotify/src/xstatus.cpp index a582c8e5c7..c15cf4e746 100644 --- a/plugins/NewXstatusNotify/src/xstatus.cpp +++ b/plugins/NewXstatusNotify/src/xstatus.cpp @@ -42,30 +42,33 @@ void FreeXSC(XSTATUSCHANGE *xsc) void RemoveLoggedEventsXStatus(MCONTACT hContact)
{
- for (auto &it : eventListXStatus.rev_iter())
+ auto T = eventListXStatus.rev_iter();
+ for (auto &it : T)
if (it->hContact == hContact) {
db_event_delete(it->hContact, it->hDBEvent);
- eventListXStatus.remove(it);
+ eventListXStatus.remove(T.indexOf(&it));
mir_free(it);
}
}
void RemoveLoggedEventsStatus(MCONTACT hContact)
{
- for (auto &it : eventListStatus.rev_iter())
+ auto T = eventListStatus.rev_iter();
+ for (auto &it : T)
if (it->hContact == hContact) {
db_event_delete(it->hContact, it->hDBEvent);
- eventListStatus.remove(it);
+ eventListStatus.remove(T.indexOf(&it));
mir_free(it);
}
}
void RemoveLoggedEventsSMsg(MCONTACT hContact)
{
- for (auto &it : eventListSMsg.rev_iter())
+ auto T = eventListSMsg.rev_iter();
+ for (auto &it : T)
if (it->hContact == hContact) {
db_event_delete(it->hContact, it->hDBEvent);
- eventListSMsg.remove(it);
+ eventListSMsg.remove(T.indexOf(&it));
mir_free(it);
}
}
diff --git a/plugins/TabSRMM/src/eventpopups.cpp b/plugins/TabSRMM/src/eventpopups.cpp index b1759de869..8dff9716bb 100644 --- a/plugins/TabSRMM/src/eventpopups.cpp +++ b/plugins/TabSRMM/src/eventpopups.cpp @@ -54,13 +54,14 @@ static PLUGIN_DATAT* PU_GetByContact(const MCONTACT hContact) */
static void PU_CleanUp()
{
- for (auto &p : arPopupList.rev_iter()) {
+ auto T = arPopupList.rev_iter();
+ for (auto &p : T) {
if (p->hContact != 0)
continue;
mir_free(p->eventData);
mir_free(p);
- arPopupList.remove(p);
+ arPopupList.remove(T.indexOf(&p));
}
}
diff --git a/plugins/UserInfoEx/src/mir_contactqueue.cpp b/plugins/UserInfoEx/src/mir_contactqueue.cpp index 752a9fbbc5..9ba36425ad 100644 --- a/plugins/UserInfoEx/src/mir_contactqueue.cpp +++ b/plugins/UserInfoEx/src/mir_contactqueue.cpp @@ -83,9 +83,10 @@ void CContactQueue::RemoveAll(MCONTACT hContact) {
mir_cslock lck(_cs);
- for (auto &qi : _queue.rev_iter()) {
+ auto T = _queue.rev_iter();
+ for (auto &qi : T) {
if (qi->hContact == hContact) {
- _queue.remove(qi);
+ _queue.remove(T.indexOf(&qi));
mir_free(qi);
}
}
@@ -98,9 +99,10 @@ void CContactQueue::RemoveAllConsiderParam(MCONTACT hContact, PVOID param) {
mir_cslock lck(_cs);
- for (auto &qi : _queue.rev_iter())
+ auto T = _queue.rev_iter();
+ for (auto &qi : T)
if (qi->hContact == hContact && qi->param == param) {
- _queue.remove(qi);
+ _queue.remove(T.indexOf(&qi));
mir_free(qi);
}
}
|