From 391980ce1e890445542441eeb5d9f9cc18ae1baf Mon Sep 17 00:00:00 2001 From: George Hazan Date: Fri, 26 Jan 2018 22:31:20 +0300 Subject: code optimization --- protocols/SkypeWeb/src/skype_db.cpp | 4 +--- protocols/SkypeWeb/src/skype_icons.cpp | 12 ++++++------ protocols/SkypeWeb/src/skype_menus.cpp | 4 ++-- protocols/SkypeWeb/src/skype_utils.cpp | 6 +++--- 4 files changed, 12 insertions(+), 14 deletions(-) (limited to 'protocols/SkypeWeb') diff --git a/protocols/SkypeWeb/src/skype_db.cpp b/protocols/SkypeWeb/src/skype_db.cpp index 62210653cc..95cba6049c 100644 --- a/protocols/SkypeWeb/src/skype_db.cpp +++ b/protocols/SkypeWeb/src/skype_db.cpp @@ -150,9 +150,7 @@ void CSkypeProto::InitDBEvents() dbEventType.iconService = MODULE "/GetEventIcon"; dbEventType.textService = MODULE "/GetEventText"; - for (size_t i = 0; i < _countof(g_SkypeDBTypes); i++) { - SkypeDBType &cur = g_SkypeDBTypes[i]; - + for (auto &cur : g_SkypeDBTypes) { dbEventType.eventType = cur.type; dbEventType.descr = Translate(cur.name); dbEventType.flags |= cur.flags; diff --git a/protocols/SkypeWeb/src/skype_icons.cpp b/protocols/SkypeWeb/src/skype_icons.cpp index 13427fa894..412d0c0043 100644 --- a/protocols/SkypeWeb/src/skype_icons.cpp +++ b/protocols/SkypeWeb/src/skype_icons.cpp @@ -37,16 +37,16 @@ void CSkypeProto::InitIcons() HICON CSkypeProto::GetIcon(int iconId) { - for (size_t i = 0; i < _countof(Icons); i++) - if (Icons[i].defIconID == iconId) - return IcoLib_GetIconByHandle(Icons[i].hIcolib); + for (auto &it : Icons) + if (it.defIconID == iconId) + return IcoLib_GetIconByHandle(it.hIcolib); return nullptr; } HANDLE CSkypeProto::GetIconHandle(int iconId) { - for (size_t i = 0; i < _countof(Icons); i++) - if (Icons[i].defIconID == iconId) - return Icons[i].hIcolib; + for (auto &it : Icons) + if (it.defIconID == iconId) + return it.hIcolib; return nullptr; } \ No newline at end of file diff --git a/protocols/SkypeWeb/src/skype_menus.cpp b/protocols/SkypeWeb/src/skype_menus.cpp index 305b35ab1d..bcf3f98315 100644 --- a/protocols/SkypeWeb/src/skype_menus.cpp +++ b/protocols/SkypeWeb/src/skype_menus.cpp @@ -45,8 +45,8 @@ int CSkypeProto::OnPrebuildContactMenu(WPARAM hContact, LPARAM) int CSkypeProto::PrebuildContactMenu(WPARAM hContact, LPARAM lParam) { - for (int i = 0; i < _countof(ContactMenuItems); i++) - Menu_ShowItem(ContactMenuItems[i], false); + for (auto &it : ContactMenuItems) + Menu_ShowItem(it, false); CSkypeProto *proto = CSkypeProto::GetContactAccount(hContact); return proto ? proto->OnPrebuildContactMenu(hContact, lParam) : 0; } diff --git a/protocols/SkypeWeb/src/skype_utils.cpp b/protocols/SkypeWeb/src/skype_utils.cpp index fdb3a97b3c..cd85c2db04 100644 --- a/protocols/SkypeWeb/src/skype_utils.cpp +++ b/protocols/SkypeWeb/src/skype_utils.cpp @@ -405,9 +405,9 @@ char *CSkypeProto::RemoveHtml(const char *text) } else { // Keyword replacement - for (int j = 0; j < _countof(htmlEntities); j++) { - if (!mir_strcmpi(entity.c_str(), htmlEntities[j].entity)) { - new_string += htmlEntities[j].symbol; + for (auto &it : htmlEntities) { + if (!mir_strcmpi(entity.c_str(), it.entity)) { + new_string += it.symbol; found = true; break; } -- cgit v1.2.3