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/UserInfoEx/src/mir_contactqueue.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'plugins/UserInfoEx/src') 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); } } -- cgit v1.2.3