diff options
author | pkasting <pkasting@chromium.org> | 2016-02-04 16:08:56 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-02-05 00:09:57 +0000 |
commit | 9022cb435a91083c86633d6672f92ca6643cb229 (patch) | |
tree | be1758ca65722b328468c626996f9822e0afe5b5 /extensions/common | |
parent | 44a33be0211fae0485f4e77b8c7d6c5190069066 (diff) | |
download | chromium_src-9022cb435a91083c86633d6672f92ca6643cb229.zip chromium_src-9022cb435a91083c86633d6672f92ca6643cb229.tar.gz chromium_src-9022cb435a91083c86633d6672f92ca6643cb229.tar.bz2 |
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}
Diffstat (limited to 'extensions/common')
-rw-r--r-- | extensions/common/permissions/socket_permission_entry.cc | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/extensions/common/permissions/socket_permission_entry.cc b/extensions/common/permissions/socket_permission_entry.cc index fdb6de8..a6fbb3b 100644 --- a/extensions/common/permissions/socket_permission_entry.cc +++ b/extensions/common/permissions/socket_permission_entry.cc @@ -31,8 +31,8 @@ const uint16_t kWildcardPortNumber = 0; const uint16_t kInvalidPort = 65535; bool StartsOrEndsWithWhitespace(const std::string& str) { - return !str.empty() && (base::IsUnicodeWhitespace(str[0]) || - base::IsUnicodeWhitespace(str[str.length() - 1])); + return !str.empty() && (base::IsUnicodeWhitespace(str.front()) || + base::IsUnicodeWhitespace(str.back())); } } // namespace |