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

Unified Diff: tools/gn/escape.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 side-by-side diff with in-line comments
Download patch
Index: tools/gn/escape.cc
diff --git a/tools/gn/escape.cc b/tools/gn/escape.cc
index 3104cb8313391e4ce33a41b3b061553e4220efec..08d893ea18690cac18f916a949005a2627d4ae85 100644
--- a/tools/gn/escape.cc
+++ b/tools/gn/escape.cc
@@ -44,18 +44,18 @@ void EscapeStringToString_Ninja(const base::StringPiece& str,
const EscapeOptions& options,
DestString* dest,
bool* needed_quoting) {
- for (size_t i = 0; i < str.size(); i++)
- NinjaEscapeChar(str[i], dest);
+ for (const auto& elem : str)
+ NinjaEscapeChar(elem, dest);
}
template<typename DestString>
void EscapeStringToString_NinjaPreformatted(const base::StringPiece& str,
DestString* dest) {
// Only Ninja-escape $.
- for (size_t i = 0; i < str.size(); i++) {
- if (str[i] == '$')
+ for (const auto& elem : str) {
+ if (elem == '$')
dest->push_back('$');
- dest->push_back(str[i]);
+ dest->push_back(elem);
}
}
@@ -118,26 +118,26 @@ void EscapeStringToString_PosixNinjaFork(const base::StringPiece& str,
const EscapeOptions& options,
DestString* dest,
bool* needed_quoting) {
- for (size_t i = 0; i < str.size(); i++) {
- if (str[i] == '$' || str[i] == ' ') {
+ for (const auto& elem : str) {
+ if (elem == '$' || elem == ' ') {
// Space and $ are special to both Ninja and the shell. '$' escape for
// Ninja, then backslash-escape for the shell.
dest->push_back('\\');
dest->push_back('$');
- dest->push_back(str[i]);
- } else if (str[i] == ':') {
+ dest->push_back(elem);
+ } else if (elem == ':') {
// Colon is the only other Ninja special char, which is not special to
// the shell.
dest->push_back('$');
dest->push_back(':');
- } else if (static_cast<unsigned>(str[i]) >= 0x80 ||
- !kShellValid[static_cast<int>(str[i])]) {
+ } else if (static_cast<unsigned>(elem) >= 0x80 ||
+ !kShellValid[static_cast<int>(elem)]) {
// All other invalid shell chars get backslash-escaped.
dest->push_back('\\');
- dest->push_back(str[i]);
+ dest->push_back(elem);
} else {
// Everything else is a literal.
- dest->push_back(str[i]);
+ dest->push_back(elem);
}
}
}
« no previous file with comments | « tools/gn/err.cc ('k') | tools/gn/exec_process.cc » ('j') | tools/gn/ninja_build_writer.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698