From 422190e1ff0acc3a4d2349e00538a68d66f1d6aa Mon Sep 17 00:00:00 2001 From: David Sanders Date: Tue, 27 Oct 2020 10:22:24 -0700 Subject: [PATCH] chore: change some for loops to range-based (#26182) --- chromium_src/chrome/browser/process_singleton_posix.cc | 5 ++--- .../browser/ui/views/frame/global_menu_bar_registrar_x11.cc | 5 ++--- shell/browser/api/electron_api_app.cc | 6 +++--- shell/common/api/electron_api_v8_util.cc | 6 +++--- shell/common/api/electron_bindings.cc | 5 +---- 5 files changed, 11 insertions(+), 16 deletions(-) diff --git a/chromium_src/chrome/browser/process_singleton_posix.cc b/chromium_src/chrome/browser/process_singleton_posix.cc index 33ea04797810..ab74dcc6e198 100644 --- a/chromium_src/chrome/browser/process_singleton_posix.cc +++ b/chromium_src/chrome/browser/process_singleton_posix.cc @@ -826,10 +826,9 @@ ProcessSingleton::NotifyResult ProcessSingleton::NotifyOtherProcessWithTimeout( to_send.append(current_dir.value()); const std::vector& argv = electron::ElectronCommandLine::argv(); - for (std::vector::const_iterator it = argv.begin(); - it != argv.end(); ++it) { + for (const auto& arg : argv) { to_send.push_back(kTokenDelimiter); - to_send.append(*it); + to_send.append(arg); } // Send the message diff --git a/chromium_src/chrome/browser/ui/views/frame/global_menu_bar_registrar_x11.cc b/chromium_src/chrome/browser/ui/views/frame/global_menu_bar_registrar_x11.cc index 32aa74606b61..0c419e06f6de 100644 --- a/chromium_src/chrome/browser/ui/views/frame/global_menu_bar_registrar_x11.cc +++ b/chromium_src/chrome/browser/ui/views/frame/global_menu_bar_registrar_x11.cc @@ -122,8 +122,7 @@ void GlobalMenuBarRegistrarX11::OnNameOwnerChanged(GObject* /* ignored */, GParamSpec* /* ignored */) { // If the name owner changed, we need to reregister all the live x11::Window // with the system. - for (std::set::const_iterator it = live_windows_.begin(); - it != live_windows_.end(); ++it) { - RegisterXWindow(*it); + for (const auto& window : live_windows_) { + RegisterXWindow(window); } } diff --git a/shell/browser/api/electron_api_app.cc b/shell/browser/api/electron_api_app.cc index ea3756dd6d39..bf3968f7135e 100644 --- a/shell/browser/api/electron_api_app.cc +++ b/shell/browser/api/electron_api_app.cc @@ -536,10 +536,10 @@ void OnClientCertificateSelected( data.c_str(), data.length(), net::X509Certificate::FORMAT_AUTO); if (!certs.empty()) { scoped_refptr cert(certs[0].get()); - for (size_t i = 0; i < identities->size(); ++i) { - if (cert->EqualsExcludingChain((*identities)[i]->certificate())) { + for (auto& identity : *identities) { + if (cert->EqualsExcludingChain(identity->certificate())) { net::ClientCertIdentity::SelfOwningAcquirePrivateKey( - std::move((*identities)[i]), + std::move(identity), base::BindRepeating(&GotPrivateKey, delegate, std::move(cert))); break; } diff --git a/shell/common/api/electron_api_v8_util.cc b/shell/common/api/electron_api_v8_util.cc index 23dbada47338..1879d302a501 100644 --- a/shell/common/api/electron_api_v8_util.cc +++ b/shell/common/api/electron_api_v8_util.cc @@ -122,9 +122,9 @@ void ClearWeaklyTrackedValues() { std::vector> GetWeaklyTrackedValues(v8::Isolate* isolate) { std::vector> locals; - for (size_t i = 0; i < weakly_tracked_values.size(); i++) { - if (!weakly_tracked_values[i].IsEmpty()) - locals.push_back(weakly_tracked_values[i].Get(isolate)); + for (const auto& value : weakly_tracked_values) { + if (!value.IsEmpty()) + locals.push_back(value.Get(isolate)); } return locals; } diff --git a/shell/common/api/electron_bindings.cc b/shell/common/api/electron_bindings.cc index 4875fe85f289..d043980e8dff 100644 --- a/shell/common/api/electron_bindings.cc +++ b/shell/common/api/electron_bindings.cc @@ -109,10 +109,7 @@ void ElectronBindings::ActivateUVLoop(v8::Isolate* isolate) { // static void ElectronBindings::OnCallNextTick(uv_async_t* handle) { auto* self = static_cast(handle->data); - for (std::list::const_iterator it = - self->pending_next_ticks_.begin(); - it != self->pending_next_ticks_.end(); ++it) { - node::Environment* env = *it; + for (auto* env : self->pending_next_ticks_) { gin_helper::Locker locker(env->isolate()); v8::Context::Scope context_scope(env->context()); v8::HandleScope handle_scope(env->isolate());