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

Unified Diff: tools/gn/visibility.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, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/gn/value_extractors.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gn/visibility.cc
diff --git a/tools/gn/visibility.cc b/tools/gn/visibility.cc
index 0dbad167cf0c6b38b607977176148b4b37df7da5..a61a5cd9c45f7effb57fd053be21ddaf29a6122e 100644
--- a/tools/gn/visibility.cc
+++ b/tools/gn/visibility.cc
@@ -30,9 +30,8 @@ bool Visibility::Set(const SourceDir& current_dir,
return false;
}
- const std::vector<Value>& list = value.list_value();
- for (size_t i = 0; i < list.size(); i++) {
- patterns_.push_back(LabelPattern::GetPattern(current_dir, list[i], err));
+ for (const auto& item : value.list_value()) {
+ patterns_.push_back(LabelPattern::GetPattern(current_dir, item, err));
if (err->has_error())
return false;
}
@@ -54,8 +53,8 @@ void Visibility::SetPrivate(const SourceDir& current_dir) {
}
bool Visibility::CanSeeMe(const Label& label) const {
- for (size_t i = 0; i < patterns_.size(); i++) {
- if (patterns_[i].Matches(label))
+ for (const auto& pattern : patterns_) {
+ if (pattern.Matches(label))
return true;
}
return false;
@@ -76,8 +75,8 @@ std::string Visibility::Describe(int indent, bool include_brackets) const {
inner_indent_string += " ";
}
- for (size_t i = 0; i < patterns_.size(); i++)
- result += inner_indent_string + patterns_[i].Describe() + "\n";
+ for (const auto& pattern : patterns_)
+ result += inner_indent_string + pattern.Describe() + "\n";
if (include_brackets)
result += outer_indent_string + "]\n";
« no previous file with comments | « tools/gn/value_extractors.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698