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/UserInfoEx/src/mir_contactqueue.cpp | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'plugins/UserInfoEx/src') diff --git a/plugins/UserInfoEx/src/mir_contactqueue.cpp b/plugins/UserInfoEx/src/mir_contactqueue.cpp index 9a734ba968..752a9fbbc5 100644 --- a/plugins/UserInfoEx/src/mir_contactqueue.cpp +++ b/plugins/UserInfoEx/src/mir_contactqueue.cpp @@ -71,8 +71,8 @@ void CContactQueue::RemoveAll() { mir_cslock lck(_cs); - for (int i = _queue.getCount() - 1; i >= 0; --i) - mir_free(_queue[i]); + for (auto &it : _queue) + mir_free(it); _queue.destroy(); } @@ -83,10 +83,9 @@ void CContactQueue::RemoveAll(MCONTACT hContact) { mir_cslock lck(_cs); - for (int i = _queue.getCount() - 1; i >= 0; --i) { - CQueueItem *qi = _queue[i]; + for (auto &qi : _queue.rev_iter()) { if (qi->hContact == hContact) { - _queue.remove(i); + _queue.remove(qi); mir_free(qi); } } @@ -99,13 +98,11 @@ void CContactQueue::RemoveAllConsiderParam(MCONTACT hContact, PVOID param) { mir_cslock lck(_cs); - for (int i = _queue.getCount() - 1; i >= 0; --i) { - CQueueItem *qi = _queue[i]; + for (auto &qi : _queue.rev_iter()) if (qi->hContact == hContact && qi->param == param) { - _queue.remove(i); + _queue.remove(qi); mir_free(qi); } - } } ///////////////////////////////////////////////////////////////////////////////////////// @@ -125,8 +122,8 @@ BOOL CContactQueue::AddIfDontHave(int waitTime, MCONTACT hContact, PVOID param) { mir_cslock lck(_cs); - for (int i = _queue.getCount() - 1; i >= 0; --i) - if (_queue[i]->hContact == hContact) + for (auto &qi : _queue.rev_iter()) + if (qi->hContact == hContact) return FALSE; return InternalAdd(waitTime, hContact, param); -- cgit v1.2.3