Modernize: Use range-based for loops for readability (#762)

Also run clang-format on these files as requested
This commit is contained in:
Andy Maloney
2019-10-05 15:20:17 -04:00
committed by Jesse Beder
parent 21d75fa4cd
commit b650bc8287
7 changed files with 37 additions and 37 deletions

View File

@@ -199,11 +199,11 @@ bool IsValidPlainScalar(const std::string& str, FlowType::value flowType,
bool IsValidSingleQuotedScalar(const std::string& str, bool escapeNonAscii) {
// TODO: check for non-printable characters?
for (std::size_t i = 0; i < str.size(); i++) {
if (escapeNonAscii && (0x80 <= static_cast<unsigned char>(str[i]))) {
for (char ch : str) {
if (escapeNonAscii && (0x80 <= static_cast<unsigned char>(ch))) {
return false;
}
if (str[i] == '\n') {
if (ch == '\n') {
return false;
}
}
@@ -217,8 +217,8 @@ bool IsValidLiteralScalar(const std::string& str, FlowType::value flowType,
}
// TODO: check for non-printable characters?
for (std::size_t i = 0; i < str.size(); i++) {
if (escapeNonAscii && (0x80 <= static_cast<unsigned char>(str[i]))) {
for (char ch : str) {
if (escapeNonAscii && (0x80 <= static_cast<unsigned char>(ch))) {
return false;
}
}