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

Unified Diff: chrome/browser/net/safe_search_util.cc

Issue 2695883003: Change uses of base::JoinString to pass StringPieces where possible. (Closed)
Patch Set: Remove dependency CL. Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/net/safe_search_util.cc
diff --git a/chrome/browser/net/safe_search_util.cc b/chrome/browser/net/safe_search_util.cc
index cc1f6ded87a0c8f23fcc05bdcfb8298fe889a988..ba59b774e3a76fbdda873c94d3da106586b89dca 100644
--- a/chrome/browser/net/safe_search_util.cc
+++ b/chrome/browser/net/safe_search_util.cc
@@ -33,12 +33,12 @@ const char kYouTubeRestrictHeaderValueStrict[] = "Strict";
// Returns whether a URL parameter, |first_parameter| (e.g. foo=bar), has the
// same key as the the |second_parameter| (e.g. foo=baz). Both parameters
// must be in key=value form.
-bool HasSameParameterKey(const std::string& first_parameter,
- const std::string& second_parameter) {
+bool HasSameParameterKey(base::StringPiece first_parameter,
+ base::StringPiece second_parameter) {
DCHECK(second_parameter.find("=") != std::string::npos);
// Prefix for "foo=bar" is "foo=".
- std::string parameter_prefix = second_parameter.substr(
- 0, second_parameter.find("=") + 1);
+ base::StringPiece parameter_prefix =
+ second_parameter.substr(0, second_parameter.find("=") + 1);
return base::StartsWith(first_parameter, parameter_prefix,
base::CompareCase::INSENSITIVE_ASCII);
}
@@ -47,11 +47,11 @@ bool HasSameParameterKey(const std::string& first_parameter,
// so that SafeSearch is active. |query| is the string to examine and the
// return value is the |query| string modified such that SafeSearch is active.
std::string AddSafeSearchParameters(const std::string& query) {
- std::vector<std::string> new_parameters;
+ std::vector<base::StringPiece> new_parameters;
std::string safe_parameter = chrome::kSafeSearchSafeParameter;
std::string ssui_parameter = chrome::kSafeSearchSsuiParameter;
- for (const std::string& param : base::SplitString(
+ for (const base::StringPiece& param : base::SplitStringPiece(
query, "&", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL)) {
if (!HasSameParameterKey(param, safe_parameter) &&
!HasSameParameterKey(param, ssui_parameter)) {
« no previous file with comments | « chrome/browser/extensions/webstore_installer.cc ('k') | chrome/browser/spellchecker/spellcheck_service_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698