From ef92dbefb269e1ca548ccb7a7fecb1d69c3a87fe Mon Sep 17 00:00:00 2001 From: "pkasting@chromium.org" Date: Fri, 30 May 2014 08:16:10 +0000 Subject: Make various string_util functions take StringPieces instead of char[]. This allows most callers to pass string literals or results of ASCIIToUTF16(), rather than construct error-prone character arrays that must be manually nul-terminated. Also cleans up various bits of the callers. BUG=104260 TEST=none Review URL: https://codereview.chromium.org/296593003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@273765 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/autocomplete/autocomplete_input.cc | 2 +- chrome/browser/autocomplete/builtin_provider.cc | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) (limited to 'chrome/browser/autocomplete') diff --git a/chrome/browser/autocomplete/autocomplete_input.cc b/chrome/browser/autocomplete/autocomplete_input.cc index af34933..f85b5db 100644 --- a/chrome/browser/autocomplete/autocomplete_input.cc +++ b/chrome/browser/autocomplete/autocomplete_input.cc @@ -133,7 +133,7 @@ AutocompleteInput::Type AutocompleteInput::Parse( if (first_non_white == base::string16::npos) return INVALID; // All whitespace. - if (text.at(first_non_white) == L'?') { + if (text[first_non_white] == L'?') { // If the first non-whitespace character is a '?', we magically treat this // as a query. return FORCED_QUERY; diff --git a/chrome/browser/autocomplete/builtin_provider.cc b/chrome/browser/autocomplete/builtin_provider.cc index 5b35c75..df0fc43 100644 --- a/chrome/browser/autocomplete/builtin_provider.cc +++ b/chrome/browser/autocomplete/builtin_provider.cc @@ -107,8 +107,7 @@ void BuiltinProvider::Start(const AutocompleteInput& input, !url.has_query() && !url.has_ref()) { // Include the path for sub-pages (e.g. "chrome://settings/browser"). base::string16 host_and_path = base::UTF8ToUTF16(url.host() + url.path()); - base::TrimString(host_and_path, base::ASCIIToUTF16("/").c_str(), - &host_and_path); + base::TrimString(host_and_path, base::ASCIIToUTF16("/"), &host_and_path); size_t match_length = kChrome.length() + host_and_path.length(); for (Builtins::const_iterator i(builtins_.begin()); (i != builtins_.end()) && (matches_.size() < kMaxMatches); ++i) { -- cgit v1.1