Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(13)

Issue 1182453004: Write new Starts/EndsWith and convert FilePath functions to StringPiece. (Closed)

Created:
5 years, 6 months ago by brettw
Modified:
5 years, 5 months ago
Reviewers:
Nico, Peter Kasting
CC:
chromium-reviews, grt+watch_chromium.org, erikwright+watch_chromium.org, jshin+watch_chromium.org, wfh+watch_chromium.org
Base URL:
https://chromium.googlesource.com/chromium/src.git@string_util
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Write new Starts/EndsWith and convert FilePath functions to StringPiece. When I moved StartsWith and EndsWith to the base namespace it became apparent that the bool parameter was frequently a source of confusion, and that the second argument is almost always a constant that we then convert to a string. This adds new versions of StartsWith/EndsWith that takes an enum for case sensitivity and string pieces for the string inputs. The existing functions used a locale-dependent case insensitive comparison that is marked with an old bug number that such comparisons are probably wrong. With this change, I moved the case insensitive comparisons to ASCII ones. Only callers in base are updated. The rest of the calls go through a compatibility layer. The compatibility layer keeps the local-dependent compares for the 16-bit string comparisons to avoid breaking things subtly. There are relatively few calls to the 16-bit version, and most use constants for the prefix/suffix (which wouldn't be affected by the locale), so there should be few callers to audit in a later pass to go to pure ASCII comparisons. The 8-bit versions now always use the ASCII case-insensitive comparisons. This should be the only change in this patch that can affect the behavior of the program. Code doing locale-dependent 8-bit tolower() calls (what the old code ended up doing) is almost certainly wrong. UTF-8 strings will be mangled. The only 8-bit non-UTF-8 strings we have are typically Posix file paths and Posix file paths are case-sensitive. I'm not very concerned about regressions from this change. Use StringPiece in FilePath for input arguments. This wasn't done before because we had no StringPiece16 until more recently. Constants are frequently passed as input to some of the functions, especially Append, so this will save some string allocations. Unfortunately, this is more likely to affect unit tests that the real browser. This is combined with the StartsWith/EndsWith changes because I started changing FilePath when updating its use of StartsWith. The FilePath changes should have no observable effect on the product. BUG=24917 Committed: https://crrev.com/89365dc80aa9ea343cea0fe48fdeb702b23726a2 Cr-Commit-Position: refs/heads/master@{#334555}

Patch Set 1 #

Patch Set 2 : #

Patch Set 3 : #

Patch Set 4 : save_package #

Patch Set 5 : Fix save_package using #

Total comments: 12

Patch Set 6 : #

Patch Set 7 : default back #

Total comments: 2
Unified diffs Side-by-side diffs Delta from patch set Stats (+236 lines, -138 lines) Patch
M base/files/file_path.h View 8 chunks +19 lines, -21 lines 0 comments Download
M base/files/file_path.cc View 1 2 3 21 chunks +61 lines, -58 lines 0 comments Download
M base/strings/string_util.h View 1 2 3 4 5 1 chunk +45 lines, -17 lines 2 comments Download
M base/strings/string_util.cc View 1 2 3 4 5 6 1 chunk +94 lines, -28 lines 0 comments Download
M base/sys_info.cc View 1 chunk +1 line, -1 line 0 comments Download
M base/version.cc View 1 2 3 4 5 3 chunks +10 lines, -8 lines 0 comments Download
M base/win/win_util.cc View 1 1 chunk +2 lines, -2 lines 0 comments Download
M content/browser/download/save_package.h View 1 2 3 4 1 chunk +4 lines, -3 lines 0 comments Download

Messages

Total messages: 35 (15 generated)
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1182453004/20001
5 years, 6 months ago (2015-06-12 21:47:41 UTC) #2
commit-bot: I haz the power
Dry run: Try jobs failed on following builders: linux_chromium_compile_dbg_32_ng on tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/linux_chromium_compile_dbg_32_ng/builds/62714) ios_dbg_simulator_ninja on ...
5 years, 6 months ago (2015-06-12 21:53:32 UTC) #4
brettw
I used an enum class for my new enum. Originally I didn't and had CASE_SENSITIVE ...
5 years, 6 months ago (2015-06-12 23:06:04 UTC) #6
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1182453004/40001
5 years, 6 months ago (2015-06-12 23:50:51 UTC) #8
commit-bot: I haz the power
Dry run: Try jobs failed on following builders: android_chromium_gn_compile_dbg on tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/android_chromium_gn_compile_dbg/builds/81256)
5 years, 6 months ago (2015-06-13 00:19:03 UTC) #10
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1182453004/60001
5 years, 6 months ago (2015-06-13 00:42:11 UTC) #12
commit-bot: I haz the power
Dry run: Try jobs failed on following builders: android_chromium_gn_compile_dbg on tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/android_chromium_gn_compile_dbg/builds/81284)
5 years, 6 months ago (2015-06-13 01:02:48 UTC) #14
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1182453004/80001
5 years, 6 months ago (2015-06-13 01:27:52 UTC) #16
commit-bot: I haz the power
Dry run: This issue passed the CQ dry run.
5 years, 6 months ago (2015-06-13 03:30:26 UTC) #18
Peter Kasting
LGTM https://codereview.chromium.org/1182453004/diff/80001/base/strings/string_util.cc File base/strings/string_util.cc (right): https://codereview.chromium.org/1182453004/diff/80001/base/strings/string_util.cc#newcode529 base/strings/string_util.cc:529: default: Nit: Does this fail to compile without ...
5 years, 6 months ago (2015-06-15 20:41:40 UTC) #19
brettw
Thanks https://codereview.chromium.org/1182453004/diff/80001/base/strings/string_util.cc File base/strings/string_util.cc (right): https://codereview.chromium.org/1182453004/diff/80001/base/strings/string_util.cc#newcode529 base/strings/string_util.cc:529: default: On 2015/06/15 20:41:39, Peter Kasting wrote: > ...
5 years, 6 months ago (2015-06-15 23:00:48 UTC) #20
Peter Kasting
https://codereview.chromium.org/1182453004/diff/80001/base/version.cc File base/version.cc (right): https://codereview.chromium.org/1182453004/diff/80001/base/version.cc#newcode104 base/version.cc:104: version_string = wildcard_string.substr(0, wildcard_string.size() - 2); On 2015/06/15 23:00:48, ...
5 years, 6 months ago (2015-06-16 00:08:18 UTC) #21
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1182453004/100001
5 years, 6 months ago (2015-06-16 03:40:23 UTC) #24
commit-bot: I haz the power
Try jobs failed on following builders: android_chromium_gn_compile_rel on tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/android_chromium_gn_compile_rel/builds/98556)
5 years, 6 months ago (2015-06-16 03:53:36 UTC) #26
brettw
Hm, looks like the case change with no default makes some compilers unhappy, but not ...
5 years, 6 months ago (2015-06-16 04:09:25 UTC) #27
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1182453004/120001
5 years, 6 months ago (2015-06-16 04:11:19 UTC) #30
commit-bot: I haz the power
Committed patchset #7 (id:120001)
5 years, 6 months ago (2015-06-16 05:53:01 UTC) #31
commit-bot: I haz the power
Patchset 7 (id:??) landed as https://crrev.com/89365dc80aa9ea343cea0fe48fdeb702b23726a2 Cr-Commit-Position: refs/heads/master@{#334555}
5 years, 6 months ago (2015-06-16 05:53:45 UTC) #32
Nico
https://codereview.chromium.org/1182453004/diff/120001/base/strings/string_util.h File base/strings/string_util.h (right): https://codereview.chromium.org/1182453004/diff/120001/base/strings/string_util.h#newcode338 base/strings/string_util.h:338: // results to a case-sensitive comparison. This suggestion won't ...
5 years, 5 months ago (2015-07-06 17:29:37 UTC) #34
brettw
5 years, 5 months ago (2015-07-06 17:48:14 UTC) #35
Message was sent while issue was closed.
https://codereview.chromium.org/1182453004/diff/120001/base/strings/string_ut...
File base/strings/string_util.h (right):

https://codereview.chromium.org/1182453004/diff/120001/base/strings/string_ut...
base/strings/string_util.h:338: // results to a case-sensitive comparison.
Good find! I'll follow up with Jungskik on writing better advice here.

Powered by Google App Engine
This is Rietveld 408576698