Skip to content

Commit ccb471e

Browse files
chore: change some for loops to range-based (electron#26263)
Co-authored-by: David Sanders <dsanders11@ucsbalum.com>
1 parent f44880f commit ccb471e

File tree

5 files changed

+11
-16
lines changed

5 files changed

+11
-16
lines changed

chromium_src/chrome/browser/process_singleton_posix.cc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -826,10 +826,9 @@ ProcessSingleton::NotifyResult ProcessSingleton::NotifyOtherProcessWithTimeout(
826826
to_send.append(current_dir.value());
827827

828828
const std::vector<std::string>& argv = electron::ElectronCommandLine::argv();
829-
for (std::vector<std::string>::const_iterator it = argv.begin();
830-
it != argv.end(); ++it) {
829+
for (const auto& arg : argv) {
831830
to_send.push_back(kTokenDelimiter);
832-
to_send.append(*it);
831+
to_send.append(arg);
833832
}
834833

835834
// Send the message

chromium_src/chrome/browser/ui/views/frame/global_menu_bar_registrar_x11.cc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,7 @@ void GlobalMenuBarRegistrarX11::OnNameOwnerChanged(GObject* /* ignored */,
122122
GParamSpec* /* ignored */) {
123123
// If the name owner changed, we need to reregister all the live x11::Window
124124
// with the system.
125-
for (std::set<x11::Window>::const_iterator it = live_windows_.begin();
126-
it != live_windows_.end(); ++it) {
127-
RegisterXWindow(*it);
125+
for (const auto& window : live_windows_) {
126+
RegisterXWindow(window);
128127
}
129128
}

shell/browser/api/electron_api_app.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -536,10 +536,10 @@ void OnClientCertificateSelected(
536536
data.c_str(), data.length(), net::X509Certificate::FORMAT_AUTO);
537537
if (!certs.empty()) {
538538
scoped_refptr<net::X509Certificate> cert(certs[0].get());
539-
for (size_t i = 0; i < identities->size(); ++i) {
540-
if (cert->EqualsExcludingChain((*identities)[i]->certificate())) {
539+
for (auto& identity : *identities) {
540+
if (cert->EqualsExcludingChain(identity->certificate())) {
541541
net::ClientCertIdentity::SelfOwningAcquirePrivateKey(
542-
std::move((*identities)[i]),
542+
std::move(identity),
543543
base::BindRepeating(&GotPrivateKey, delegate, std::move(cert)));
544544
break;
545545
}

shell/common/api/electron_api_v8_util.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,9 @@ void ClearWeaklyTrackedValues() {
122122

123123
std::vector<v8::Local<v8::Value>> GetWeaklyTrackedValues(v8::Isolate* isolate) {
124124
std::vector<v8::Local<v8::Value>> locals;
125-
for (size_t i = 0; i < weakly_tracked_values.size(); i++) {
126-
if (!weakly_tracked_values[i].IsEmpty())
127-
locals.push_back(weakly_tracked_values[i].Get(isolate));
125+
for (const auto& value : weakly_tracked_values) {
126+
if (!value.IsEmpty())
127+
locals.push_back(value.Get(isolate));
128128
}
129129
return locals;
130130
}

shell/common/api/electron_bindings.cc

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,7 @@ void ElectronBindings::ActivateUVLoop(v8::Isolate* isolate) {
111111
// static
112112
void ElectronBindings::OnCallNextTick(uv_async_t* handle) {
113113
auto* self = static_cast<ElectronBindings*>(handle->data);
114-
for (std::list<node::Environment*>::const_iterator it =
115-
self->pending_next_ticks_.begin();
116-
it != self->pending_next_ticks_.end(); ++it) {
117-
node::Environment* env = *it;
114+
for (auto* env : self->pending_next_ticks_) {
118115
gin_helper::Locker locker(env->isolate());
119116
v8::Context::Scope context_scope(env->context());
120117
v8::HandleScope handle_scope(env->isolate());

0 commit comments

Comments
 (0)