Allow string::front() and back() and update the codebase to use back().
I searched for "length() - 1]", which won't find all potential sites to use
back(), but should hit a reasonable number. These were all converted.
I don't consider str.front() to be vastly more readable than str[0], so I made
no effort to seek these out and change them. I did change code to use front()
when it would make for better parallel structure with a place I was making use
back(), e.g.:
if (str[0] == 'x' && str[str.length() - 1] == 'y') {
...was transformed to:
if (str.front() == 'x' && str.back() == 'y') {
...and not:
if (str[0] == 'x' && str.back() == 'y') {
I also added front() and back() methods to StringPiece so people wouldn't need to distinguish between string and StringPiece for these purposes.
BUG=none
TEST=none
Review URL: https://codereview.chromium.org/1663253004
Cr-Commit-Position: refs/heads/master@{#373672}
37 files changed