Browse Source

Some manual change to for-ranged loop.

Use "const auto&" where possible.
Haojian Wu 8 years ago
parent
commit
4ac4dacffe

+ 1 - 1
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, &current_size);

+ 1 - 1
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);

+ 1 - 1
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)

+ 1 - 1
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();
 }
 

+ 1 - 1
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;

+ 2 - 1
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);
 }
 

+ 1 - 1
atom/renderer/atom_render_view_observer.cc

@@ -132,7 +132,7 @@ void AtomRenderViewObserver::DraggableRegionsChanged(blink::WebFrame* frame) {
   blink::WebVector<blink::WebDraggableRegion> webregions =
       frame->document().draggableRegions();
   std::vector<DraggableRegion> regions;
-  for (auto& webregion : webregions) {
+  for (const auto& webregion : webregions) {
     DraggableRegion region;
     region.bounds = webregion.bounds;
     region.draggable = webregion.draggable;

+ 1 - 1
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);
   }