Reland of place string::find(prefix) == 0 pattern with base::StartsWith(). (patchset #1 id:1 of https://codereview.chromium.org/2131933002/ )
Reason for revert:
Reverting this revert since https://codereview.chromium.org/2135653002/
seems to fix the issue
Original issue's description:
> Revert of Replace string::find(prefix) == 0 pattern with base::StartsWith(). (patchset #2 id:20001 of https://codereview.chromium.org/2121513002/ )
>
> Reason for revert:
> Bisect believes that this CL caused the Win builder to break.
>
> https://build.chromium.org/p/chromium/builders/Win%20x64/builds/2267
> https://build.chromium.org/p/chromium/builders/Win/builds/45048
>
> For context see:
> https://bugs.chromium.org/p/chromium/issues/detail?id=626539
>
> Original issue's description:
> > Replace string::find(prefix) == 0 pattern with base::StartsWith().
> >
> > base::StartsWith() should be O(|prefix|) whereas string::find() is
> > pretty bad, O(|string| * |prefix|).
> >
> > [email protected]
> > BUG=None
> > Test=None, internal cleanup.
> > CQ_INCLUDE_TRYBOTS=tryserver.chromium.win:win10_chromium_x64_rel_ng
> >
> > Committed: https://crrev.com/53bfbe932191085b5d69f824a9923bccc26d58dc
> > Cr-Commit-Position: refs/heads/master@{#404307}
>
> [email protected],[email protected]
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=None
>
> Committed: https://crrev.com/f635836294b0221de8531e3ab3720d7fc18e65cd
> Cr-Commit-Position: refs/heads/master@{#404341}
[email protected],[email protected]
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=None
Review-Url: https://codereview.chromium.org/2136453004
Cr-Commit-Position: refs/heads/master@{#404342}
diff --git a/chrome/browser/ui/browser_navigator_browsertest.cc b/chrome/browser/ui/browser_navigator_browsertest.cc
index 4c8c1d9..efae8f1 100644
--- a/chrome/browser/ui/browser_navigator_browsertest.cc
+++ b/chrome/browser/ui/browser_navigator_browsertest.cc
@@ -68,7 +68,7 @@
std::string url_string = url.spec();
const std::string long_prefix = "chrome://chrome/";
const std::string short_prefix = "chrome://";
- if (url_string.find(long_prefix) != 0)
+ if (!base::StartsWith(url_string, long_prefix, base::CompareCase::SENSITIVE))
return url;
url_string.replace(0, long_prefix.length(), short_prefix);
return GURL(url_string);