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

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

Issue 986113002: tools/gn: Convert for loops to use the new range-based loops in C++11. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more fixes Created 5 years, 9 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
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/pattern.h" 5 #include "tools/gn/pattern.h"
6 6
7 #include "tools/gn/value.h" 7 #include "tools/gn/value.h"
8 8
9 namespace { 9 namespace {
10 10
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 160
161 void PatternList::SetFromValue(const Value& v, Err* err) { 161 void PatternList::SetFromValue(const Value& v, Err* err) {
162 patterns_.clear(); 162 patterns_.clear();
163 163
164 if (v.type() != Value::LIST) { 164 if (v.type() != Value::LIST) {
165 *err = Err(v.origin(), "This value must be a list."); 165 *err = Err(v.origin(), "This value must be a list.");
166 return; 166 return;
167 } 167 }
168 168
169 const std::vector<Value>& list = v.list_value(); 169 const std::vector<Value>& list = v.list_value();
170 for (size_t i = 0; i < list.size(); i++) { 170 for (const auto& elem : list) {
171 if (!list[i].VerifyTypeIs(Value::STRING, err)) 171 if (!elem.VerifyTypeIs(Value::STRING, err))
172 return; 172 return;
173 patterns_.push_back(Pattern(list[i].string_value())); 173 patterns_.push_back(Pattern(elem.string_value()));
174 } 174 }
175 } 175 }
176 176
177 bool PatternList::MatchesString(const std::string& s) const { 177 bool PatternList::MatchesString(const std::string& s) const {
178 for (size_t i = 0; i < patterns_.size(); i++) { 178 for (const auto& pattern: patterns_) {
scottmg 2015/03/23 17:24:20 nit; space before :
tfarina 2015/03/25 14:14:31 Done.
179 if (patterns_[i].MatchesString(s)) 179 if (pattern.MatchesString(s))
180 return true; 180 return true;
181 } 181 }
182 return false; 182 return false;
183 } 183 }
184 184
185 bool PatternList::MatchesValue(const Value& v) const { 185 bool PatternList::MatchesValue(const Value& v) const {
186 if (v.type() == Value::STRING) 186 if (v.type() == Value::STRING)
187 return MatchesString(v.string_value()); 187 return MatchesString(v.string_value());
188 return false; 188 return false;
189 } 189 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698