From 477a6ea70d0bb1b1dfe9cbd9a15b6dad0284ddeb Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 21 Feb 2018 18:40:03 +0300 Subject: all another C++'11 iterators --- plugins/FavContacts/src/contact_cache.cpp | 4 ++-- plugins/FavContacts/src/favlist.h | 4 ++-- plugins/FavContacts/src/menu.cpp | 10 +++++----- 3 files changed, 9 insertions(+), 9 deletions(-) (limited to 'plugins/FavContacts/src') diff --git a/plugins/FavContacts/src/contact_cache.cpp b/plugins/FavContacts/src/contact_cache.cpp index d6039f3782..d60cd00d84 100644 --- a/plugins/FavContacts/src/contact_cache.cpp +++ b/plugins/FavContacts/src/contact_cache.cpp @@ -19,8 +19,8 @@ CContactCache::CContactCache() : CContactCache::~CContactCache() { - for (int i = 0; i < m_cache.getCount(); i++) - delete m_cache[i]; + for (auto &it : m_cache) + delete it; } int __cdecl CContactCache::OnDbEventAdded(WPARAM hContact, LPARAM hEvent) diff --git a/plugins/FavContacts/src/favlist.h b/plugins/FavContacts/src/favlist.h index b6ebc70f2e..c9ed5bc2c3 100644 --- a/plugins/FavContacts/src/favlist.h +++ b/plugins/FavContacts/src/favlist.h @@ -99,8 +99,8 @@ public: ~TFavContacts() { - for (int i = 0; i < this->getCount(); ++i) - delete (*this)[i]; + for (auto &it : *this) + delete it; } __forceinline int groupCount() const { return nGroups; } diff --git a/plugins/FavContacts/src/menu.cpp b/plugins/FavContacts/src/menu.cpp index f0c8e1072e..4770696e65 100644 --- a/plugins/FavContacts/src/menu.cpp +++ b/plugins/FavContacts/src/menu.cpp @@ -458,21 +458,21 @@ int ShowMenu(bool centered) g_maxItemWidth /= favList.groupCount(); prevGroup = nullptr; - for (int i = 0; i < favList.getCount(); ++i) { - hContact = favList[i]->getHandle(); + for (auto &it : favList) { + hContact = it->getHandle(); MEASUREITEMSTRUCT mis = { 0 }; mis.CtlID = 0; mis.CtlType = ODT_MENU; - if (!prevGroup || mir_wstrcmp(prevGroup, favList[i]->getGroup())) { + if (!prevGroup || mir_wstrcmp(prevGroup, it->getGroup())) { if (prevGroup && g_Options.bUseColumns) { szMenu.cx += szColumn.cx; szMenu.cy = max(szMenu.cy, szColumn.cy); szColumn.cx = szColumn.cy = 0; } - int groupID = -((INT_PTR)Clist_GroupExists(favList[i]->getGroup()) + 1); + int groupID = -((INT_PTR)Clist_GroupExists(it->getGroup()) + 1); AppendMenu(hMenu, MF_OWNERDRAW | MF_SEPARATOR | ((prevGroup && g_Options.bUseColumns) ? MF_MENUBREAK : 0), @@ -493,7 +493,7 @@ int ShowMenu(bool centered) szColumn.cx = max(szColumn.cx, (int)mis.itemWidth); szColumn.cy += mis.itemHeight; - prevGroup = favList[i]->getGroup(); + prevGroup = it->getGroup(); } szMenu.cx += szColumn.cx; szMenu.cy = max(szMenu.cy, szColumn.cy); -- cgit v1.2.3