From 9022cb435a91083c86633d6672f92ca6643cb229 Mon Sep 17 00:00:00 2001 From: pkasting Date: Thu, 4 Feb 2016 16:08:56 -0800 Subject: 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} --- extensions/common/permissions/socket_permission_entry.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'extensions/common') 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 -- cgit v1.1