From 4ac4dacffe2d2ae02e127699198db46a23c232c3 Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Sun, 10 Jul 2016 15:56:42 +0200 Subject: [PATCH] Some manual change to for-ranged loop. Use "const auto&" where possible. --- atom/browser/api/atom_api_session.cc | 2 +- atom/browser/common_web_contents_delegate.cc | 2 +- atom/browser/ui/accelerator_util.cc | 2 +- atom/browser/window_list.cc | 2 +- atom/common/api/atom_api_native_image.cc | 2 +- atom/common/node_bindings_mac.cc | 3 ++- atom/renderer/atom_render_view_observer.cc | 2 +- atom/utility/atom_content_utility_client.cc | 2 +- 8 files changed, 9 insertions(+), 8 deletions(-) diff --git a/atom/browser/api/atom_api_session.cc b/atom/browser/api/atom_api_session.cc index ae5854df53..c898f5f1b3 100644 --- a/atom/browser/api/atom_api_session.cc +++ b/atom/browser/api/atom_api_session.cc @@ -241,7 +241,7 @@ void OnGetBackend(disk_cache::Backend** backend_ptr, } else if (action == Session::CacheAction::STATS) { base::StringPairs stats; (*backend_ptr)->GetStats(&stats); - for (auto& stat : stats) { + for (const auto& stat : stats) { if (stat.first == "Current size") { int current_size; base::StringToInt(stat.second, ¤t_size); diff --git a/atom/browser/common_web_contents_delegate.cc b/atom/browser/common_web_contents_delegate.cc index e94203e0b5..f2f0ee8aec 100644 --- a/atom/browser/common_web_contents_delegate.cc +++ b/atom/browser/common_web_contents_delegate.cc @@ -435,7 +435,7 @@ void CommonWebContentsDelegate::DevToolsRequestFileSystems() { } base::ListValue file_system_value; - for (auto& file_system : file_systems) + for (const auto& file_system : file_systems) file_system_value.Append(CreateFileSystemValue(file_system)); web_contents_->CallClientFunction("DevToolsAPI.fileSystemsLoaded", &file_system_value, nullptr, nullptr); diff --git a/atom/browser/ui/accelerator_util.cc b/atom/browser/ui/accelerator_util.cc index 1c26af1b39..eb89bf0c35 100644 --- a/atom/browser/ui/accelerator_util.cc +++ b/atom/browser/ui/accelerator_util.cc @@ -30,7 +30,7 @@ bool StringToAccelerator(const std::string& shortcut, // Now, parse it into an accelerator. int modifiers = ui::EF_NONE; ui::KeyboardCode key = ui::VKEY_UNKNOWN; - for (auto& token : tokens) { + for (const auto& token : tokens) { bool shifted = false; ui::KeyboardCode code = atom::KeyboardCodeFromStr(token, &shifted); if (shifted) diff --git a/atom/browser/window_list.cc b/atom/browser/window_list.cc index 3568df9e6d..83bf615aad 100644 --- a/atom/browser/window_list.cc +++ b/atom/browser/window_list.cc @@ -70,7 +70,7 @@ void WindowList::RemoveObserver(WindowListObserver* observer) { // static void WindowList::CloseAllWindows() { WindowVector windows = GetInstance()->windows_; - for (auto& window : windows) + for (const auto& window : windows) window->Close(); } diff --git a/atom/common/api/atom_api_native_image.cc b/atom/common/api/atom_api_native_image.cc index f694ffe7e9..80275e26a7 100644 --- a/atom/common/api/atom_api_native_image.cc +++ b/atom/common/api/atom_api_native_image.cc @@ -63,7 +63,7 @@ float GetScaleFactorFromPath(const base::FilePath& path) { // We don't try to convert string to float here because it is very very // expensive. - for (auto& kScaleFactorPair : kScaleFactorPairs) { + for (const auto& kScaleFactorPair : kScaleFactorPairs) { if (base::EndsWith(filename, kScaleFactorPair.name, base::CompareCase::INSENSITIVE_ASCII)) return kScaleFactorPair.scale; diff --git a/atom/common/node_bindings_mac.cc b/atom/common/node_bindings_mac.cc index 6be1226ae3..cbcbdba360 100644 --- a/atom/common/node_bindings_mac.cc +++ b/atom/common/node_bindings_mac.cc @@ -54,7 +54,8 @@ void NodeBindingsMac::PollEvents() { // Wait for new libuv events. int r; do { - r = select(fd + 1, &readset, nullptr, nullptr, timeout == -1 ? nullptr : &tv); + r = select(fd + 1, &readset, nullptr, nullptr, + timeout == -1 ? nullptr : &tv); } while (r == -1 && errno == EINTR); } diff --git a/atom/renderer/atom_render_view_observer.cc b/atom/renderer/atom_render_view_observer.cc index e579165d72..45a41eef8a 100644 --- a/atom/renderer/atom_render_view_observer.cc +++ b/atom/renderer/atom_render_view_observer.cc @@ -132,7 +132,7 @@ void AtomRenderViewObserver::DraggableRegionsChanged(blink::WebFrame* frame) { blink::WebVector webregions = frame->document().draggableRegions(); std::vector regions; - for (auto& webregion : webregions) { + for (const auto& webregion : webregions) { DraggableRegion region; region.bounds = webregion.bounds; region.draggable = webregion.draggable; diff --git a/atom/utility/atom_content_utility_client.cc b/atom/utility/atom_content_utility_client.cc index 518be30510..8d4ccf6289 100644 --- a/atom/utility/atom_content_utility_client.cc +++ b/atom/utility/atom_content_utility_client.cc @@ -58,7 +58,7 @@ bool AtomContentUtilityClient::OnMessageReceived( IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP() - for (auto it = handlers_.begin(); !handled && it != handlers_.end(); ++it) { + for (auto it = handlers_.begin(); !handled && it != handlers_.end(); ++it) { handled = (*it)->OnMessageReceived(message); }