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

Unified Diff: tools/gn/operators.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/ninja_binary_target_writer.cc ('k') | tools/gn/parse_tree.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gn/operators.cc
diff --git a/tools/gn/operators.cc b/tools/gn/operators.cc
index 3a815ea34fc31bd33dba7ed0e442f3878586e2a1..78ea31b756af497f967bfd1f5eb57ab6b46fe8bc 100644
--- a/tools/gn/operators.cc
+++ b/tools/gn/operators.cc
@@ -36,20 +36,19 @@ void AppendFilteredSourcesToValue(const Scope* scope,
return;
}
- const std::vector<Value>& source_list = source.list_value();
if (!filter || filter->is_empty()) {
// No filter, append everything.
- for (size_t i = 0; i < source_list.size(); i++)
- dest->list_value().push_back(source_list[i]);
+ for (const auto& source_entry : source.list_value())
+ dest->list_value().push_back(source_entry);
return;
}
// Note: don't reserve() the dest vector here since that actually hurts
// the allocation pattern when the build script is doing multiple small
// additions.
- for (size_t i = 0; i < source_list.size(); i++) {
- if (!filter->MatchesValue(source_list[i]))
- dest->list_value().push_back(source_list[i]);
+ for (const auto& source_entry : source.list_value()) {
+ if (!filter->MatchesValue(source_entry))
+ dest->list_value().push_back(source_entry);
}
}
@@ -228,8 +227,8 @@ void ValuePlusEquals(const Scope* scope,
AppendFilteredSourcesToValue(scope, right, left);
} else {
// Normal list concat.
- for (size_t i = 0; i < right.list_value().size(); i++)
- left->list_value().push_back(right.list_value()[i]);
+ for (const auto& value : right.list_value())
+ left->list_value().push_back(value);
}
return;
« no previous file with comments | « tools/gn/ninja_binary_target_writer.cc ('k') | tools/gn/parse_tree.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698