From df6b0c988eb26339d4c7e4a1d0fe3b9717703c28 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Fri, 9 Mar 2018 19:32:32 +0300 Subject: more loop-related code cleaning --- plugins/PluginUpdater/src/DlgListNew.cpp | 3 +-- plugins/PluginUpdater/src/DlgUpdate.cpp | 11 +++++------ 2 files changed, 6 insertions(+), 8 deletions(-) (limited to 'plugins/PluginUpdater') diff --git a/plugins/PluginUpdater/src/DlgListNew.cpp b/plugins/PluginUpdater/src/DlgListNew.cpp index fa521bbcfc..81f40481b7 100644 --- a/plugins/PluginUpdater/src/DlgListNew.cpp +++ b/plugins/PluginUpdater/src/DlgListNew.cpp @@ -27,9 +27,8 @@ static void SelectAll(HWND hDlg, bool bEnable) OBJLIST &todo = *(OBJLIST *)GetWindowLongPtr(hDlg, GWLP_USERDATA); HWND hwndList = GetDlgItem(hDlg, IDC_LIST_UPDATES); - for (int i = 0; i < todo.getCount(); i++) { + for (int i = 0; i < todo.getCount(); i++) ListView_SetCheckState(hwndList, i, todo[i].bEnabled = bEnable); - } } static void ApplyDownloads(void *param) diff --git a/plugins/PluginUpdater/src/DlgUpdate.cpp b/plugins/PluginUpdater/src/DlgUpdate.cpp index 91f6358b2d..467e7e44ce 100644 --- a/plugins/PluginUpdater/src/DlgUpdate.cpp +++ b/plugins/PluginUpdater/src/DlgUpdate.cpp @@ -315,8 +315,8 @@ static INT_PTR CALLBACK DlgUpdate(HWND hDlg, UINT message, WPARAM wParam, LPARAM // Toggle the Download button bool enableOk = false; OBJLIST &todo = *(OBJLIST *)GetWindowLongPtr(hDlg, GWLP_USERDATA); - for (int i=0; i < todo.getCount(); ++i) { - if (todo[i].bEnabled) { + for (auto &it : todo) { + if (it->bEnabled) { enableOk = true; break; } @@ -423,11 +423,10 @@ static void DlgUpdateSilent(void *param) HNETLIBCONN nlc = nullptr; // Count all updates that have been enabled int count = 0; - for (int i = 0; i < UpdateFiles.getCount(); i++) { - if (UpdateFiles[i].bEnabled && !UpdateFiles[i].bDeleteOnly) { + for (auto &it : UpdateFiles) { + if (it->bEnabled && !it->bDeleteOnly) { // download update - FILEURL *pFileUrl = &UpdateFiles[i].File; - if (!DownloadFile(pFileUrl, nlc)) { + if (!DownloadFile(&it->File, nlc)) { // interrupt update as we require all components to be updated Netlib_CloseHandle(nlc); Skin_PlaySound("updatefailed"); -- cgit v1.2.3