chore: change some for loops to range-based (#26182)

This commit is contained in:
David Sanders 2020-10-27 10:22:24 -07:00 committed by GitHub
parent d8167ce138
commit 422190e1ff
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 11 additions and 16 deletions

View file

@ -826,10 +826,9 @@ ProcessSingleton::NotifyResult ProcessSingleton::NotifyOtherProcessWithTimeout(
to_send.append(current_dir.value()); to_send.append(current_dir.value());
const std::vector<std::string>& argv = electron::ElectronCommandLine::argv(); const std::vector<std::string>& argv = electron::ElectronCommandLine::argv();
for (std::vector<std::string>::const_iterator it = argv.begin(); for (const auto& arg : argv) {
it != argv.end(); ++it) {
to_send.push_back(kTokenDelimiter); to_send.push_back(kTokenDelimiter);
to_send.append(*it); to_send.append(arg);
} }
// Send the message // Send the message

View file

@ -122,8 +122,7 @@ void GlobalMenuBarRegistrarX11::OnNameOwnerChanged(GObject* /* ignored */,
GParamSpec* /* ignored */) { GParamSpec* /* ignored */) {
// If the name owner changed, we need to reregister all the live x11::Window // If the name owner changed, we need to reregister all the live x11::Window
// with the system. // with the system.
for (std::set<x11::Window>::const_iterator it = live_windows_.begin(); for (const auto& window : live_windows_) {
it != live_windows_.end(); ++it) { RegisterXWindow(window);
RegisterXWindow(*it);
} }
} }

View file

@ -536,10 +536,10 @@ void OnClientCertificateSelected(
data.c_str(), data.length(), net::X509Certificate::FORMAT_AUTO); data.c_str(), data.length(), net::X509Certificate::FORMAT_AUTO);
if (!certs.empty()) { if (!certs.empty()) {
scoped_refptr<net::X509Certificate> cert(certs[0].get()); scoped_refptr<net::X509Certificate> cert(certs[0].get());
for (size_t i = 0; i < identities->size(); ++i) { for (auto& identity : *identities) {
if (cert->EqualsExcludingChain((*identities)[i]->certificate())) { if (cert->EqualsExcludingChain(identity->certificate())) {
net::ClientCertIdentity::SelfOwningAcquirePrivateKey( net::ClientCertIdentity::SelfOwningAcquirePrivateKey(
std::move((*identities)[i]), std::move(identity),
base::BindRepeating(&GotPrivateKey, delegate, std::move(cert))); base::BindRepeating(&GotPrivateKey, delegate, std::move(cert)));
break; break;
} }

View file

@ -122,9 +122,9 @@ void ClearWeaklyTrackedValues() {
std::vector<v8::Local<v8::Value>> GetWeaklyTrackedValues(v8::Isolate* isolate) { std::vector<v8::Local<v8::Value>> GetWeaklyTrackedValues(v8::Isolate* isolate) {
std::vector<v8::Local<v8::Value>> locals; std::vector<v8::Local<v8::Value>> locals;
for (size_t i = 0; i < weakly_tracked_values.size(); i++) { for (const auto& value : weakly_tracked_values) {
if (!weakly_tracked_values[i].IsEmpty()) if (!value.IsEmpty())
locals.push_back(weakly_tracked_values[i].Get(isolate)); locals.push_back(value.Get(isolate));
} }
return locals; return locals;
} }

View file

@ -109,10 +109,7 @@ void ElectronBindings::ActivateUVLoop(v8::Isolate* isolate) {
// static // static
void ElectronBindings::OnCallNextTick(uv_async_t* handle) { void ElectronBindings::OnCallNextTick(uv_async_t* handle) {
auto* self = static_cast<ElectronBindings*>(handle->data); auto* self = static_cast<ElectronBindings*>(handle->data);
for (std::list<node::Environment*>::const_iterator it = for (auto* env : self->pending_next_ticks_) {
self->pending_next_ticks_.begin();
it != self->pending_next_ticks_.end(); ++it) {
node::Environment* env = *it;
gin_helper::Locker locker(env->isolate()); gin_helper::Locker locker(env->isolate());
v8::Context::Scope context_scope(env->context()); v8::Context::Scope context_scope(env->context());
v8::HandleScope handle_scope(env->isolate()); v8::HandleScope handle_scope(env->isolate());