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

Unified Diff: tools/gn/parse_tree.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/operators.cc ('k') | tools/gn/parser.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gn/parse_tree.cc
diff --git a/tools/gn/parse_tree.cc b/tools/gn/parse_tree.cc
index f2ddb1cd66429e3bc7fa3368205778bda16d3ac8..9b2fc3f831a06118101695b4d4116094f844e9b6 100644
--- a/tools/gn/parse_tree.cc
+++ b/tools/gn/parse_tree.cc
@@ -59,21 +59,12 @@ Comments* ParseNode::comments_mutable() {
void ParseNode::PrintComments(std::ostream& out, int indent) const {
if (comments_) {
std::string ind = IndentFor(indent + 1);
- for (std::vector<Token>::const_iterator i(comments_->before().begin());
- i != comments_->before().end();
- ++i) {
- out << ind << "+BEFORE_COMMENT(\"" << i->value() << "\")\n";
- }
- for (std::vector<Token>::const_iterator i(comments_->suffix().begin());
- i != comments_->suffix().end();
- ++i) {
- out << ind << "+SUFFIX_COMMENT(\"" << i->value() << "\")\n";
- }
- for (std::vector<Token>::const_iterator i(comments_->after().begin());
- i != comments_->after().end();
- ++i) {
- out << ind << "+AFTER_COMMENT(\"" << i->value() << "\")\n";
- }
+ for (const auto& token : comments_->before())
+ out << ind << "+BEFORE_COMMENT(\"" << token.value() << "\")\n";
+ for (const auto& token : comments_->suffix())
+ out << ind << "+SUFFIX_COMMENT(\"" << token.value() << "\")\n";
+ for (const auto& token : comments_->after())
+ out << ind << "+AFTER_COMMENT(\"" << token.value() << "\")\n";
}
}
@@ -281,8 +272,8 @@ Err BlockNode::MakeErrorDescribing(const std::string& msg,
void BlockNode::Print(std::ostream& out, int indent) const {
out << IndentFor(indent) << "BLOCK\n";
PrintComments(out, indent);
- for (size_t i = 0; i < statements_.size(); i++)
- statements_[i]->Print(out, indent + 1);
+ for (const auto& statement : statements_)
+ statement->Print(out, indent + 1);
if (end_ && end_->comments())
end_->Print(out, indent + 1);
}
@@ -463,8 +454,7 @@ Value ListNode::Execute(Scope* scope, Err* err) const {
std::vector<Value>& results = result_value.list_value();
results.reserve(contents_.size());
- for (size_t i = 0; i < contents_.size(); i++) {
- const ParseNode* cur = contents_[i];
+ for (const auto& cur : contents_) {
if (cur->AsBlockComment())
continue;
results.push_back(cur->Execute(scope, err));
@@ -493,8 +483,8 @@ Err ListNode::MakeErrorDescribing(const std::string& msg,
void ListNode::Print(std::ostream& out, int indent) const {
out << IndentFor(indent) << "LIST\n";
PrintComments(out, indent);
- for (size_t i = 0; i < contents_.size(); i++)
- contents_[i]->Print(out, indent + 1);
+ for (const auto& cur : contents_)
+ cur->Print(out, indent + 1);
if (end_ && end_->comments())
end_->Print(out, indent + 1);
}
« no previous file with comments | « tools/gn/operators.cc ('k') | tools/gn/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698