Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: tools/gn/value.cc

Issue 610293003: Replace more for loops in GN (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tools/gn/trace.cc ('k') | tools/gn/value_extractors.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "tools/gn/value.h" 5 #include "tools/gn/value.h"
6 6
7 #include "base/strings/string_number_conversions.h" 7 #include "base/strings/string_number_conversions.h"
8 #include "base/strings/string_util.h" 8 #include "base/strings/string_util.h"
9 #include "tools/gn/scope.h" 9 #include "tools/gn/scope.h"
10 10
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 result.push_back(']'); 145 result.push_back(']');
146 return result; 146 return result;
147 } 147 }
148 case SCOPE: { 148 case SCOPE: {
149 Scope::KeyValueMap scope_values; 149 Scope::KeyValueMap scope_values;
150 scope_value_->GetCurrentScopeValues(&scope_values); 150 scope_value_->GetCurrentScopeValues(&scope_values);
151 if (scope_values.empty()) 151 if (scope_values.empty())
152 return std::string("{ }"); 152 return std::string("{ }");
153 153
154 std::string result = "{\n"; 154 std::string result = "{\n";
155 for (Scope::KeyValueMap::const_iterator i = scope_values.begin(); 155 for (const auto& pair : scope_values) {
156 i != scope_values.end(); ++i) { 156 result += " " + pair.first.as_string() + " = " +
157 result += " " + i->first.as_string() + " = " + 157 pair.second.ToString(true) + "\n";
158 i->second.ToString(true) + "\n";
159 } 158 }
160 result += "}"; 159 result += "}";
161 160
162 return result; 161 return result;
163 } 162 }
164 } 163 }
165 return std::string(); 164 return std::string();
166 } 165 }
167 166
168 bool Value::VerifyTypeIs(Type t, Err* err) const { 167 bool Value::VerifyTypeIs(Type t, Err* err) const {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 // iteration code. 200 // iteration code.
202 return false; 201 return false;
203 default: 202 default:
204 return false; 203 return false;
205 } 204 }
206 } 205 }
207 206
208 bool Value::operator!=(const Value& other) const { 207 bool Value::operator!=(const Value& other) const {
209 return !operator==(other); 208 return !operator==(other);
210 } 209 }
OLDNEW
« no previous file with comments | « tools/gn/trace.cc ('k') | tools/gn/value_extractors.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698