From: Michael Lee Date: Thu, 11 Feb 2016 04:22:20 +0000 (-0800) Subject: fix -Wshadowing in String.cpp X-Git-Tag: deprecate-dynamic-initializer~77 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=116d93dbbcdc52b7d4d8bdc6b6652d23cb61b23b;p=folly.git fix -Wshadowing in String.cpp Summary: Didn't check this with -Wshadow when I first wrote it. Reviewed By: ranjeeth Differential Revision: D2926047 fb-gh-sync-id: 8391986dee2d6b5698491bd2995f039468ec684d shipit-source-id: 8391986dee2d6b5698491bd2995f039468ec684d --- diff --git a/folly/String.cpp b/folly/String.cpp index 6692c783..43404026 100644 --- a/folly/String.cpp +++ b/folly/String.cpp @@ -571,7 +571,7 @@ std::string stripLeftMargin(std::string s) { const auto sentinel = std::numeric_limits::max(); auto indent = sentinel; size_t max_length = 0; - for (auto piece = piecer.begin(); piece != piecer.end(); piece++) { + for (piece = piecer.begin(); piece != piecer.end(); piece++) { needle = std::find_if(piece->begin(), piece->end(), [](char c) { return c != ' ' && c != '\t'; }); @@ -582,11 +582,11 @@ std::string stripLeftMargin(std::string s) { } } indent = indent == sentinel ? max_length : indent; - for (auto& piece : piecer) { - if (piece.size() < indent) { - piece.clear(); + for (piece = piecer.begin(); piece != piecer.end(); piece++) { + if (piece->size() < indent) { + piece->clear(); } else { - piece.erase(piece.begin(), piece.begin() + indent); + piece->erase(piece->begin(), piece->begin() + indent); } } return join("\n", piecer);