Commit e9c90126 authored by Andrei Polushin's avatar Andrei Polushin Committed by Commit Bot

Change type of ReplaceChars() parameter.

Currently base::ReplaceChars() accepts std::string for the 3rd
parameter, and immediately converts it to base::StringPiece.

To avoid string copies on the caller side, it should accept
base::StringPiece instead.

This change became possible after r504430.

BUG=760330
TEST=base_unittests --gtest_filter=StringUtilTest.ReplaceChars

Change-Id: I9a3a4cc02cfbfb8c8a258dc077612dd5146b9592
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1930799
Auto-Submit: Andrei Polushin <anpol@yandex-team.ru>
Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Commit-Queue: Daniel Cheng <dcheng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#719410}
parent 6f3f0ed6
...@@ -237,17 +237,16 @@ bool ReplaceCharsT(const StringType& input, ...@@ -237,17 +237,16 @@ bool ReplaceCharsT(const StringType& input,
bool ReplaceChars(const string16& input, bool ReplaceChars(const string16& input,
StringPiece16 replace_chars, StringPiece16 replace_chars,
const string16& replace_with, StringPiece16 replace_with,
string16* output) { string16* output) {
return ReplaceCharsT(input, replace_chars, StringPiece16(replace_with), return ReplaceCharsT(input, replace_chars, replace_with, output);
output);
} }
bool ReplaceChars(const std::string& input, bool ReplaceChars(const std::string& input,
StringPiece replace_chars, StringPiece replace_chars,
const std::string& replace_with, StringPiece replace_with,
std::string* output) { std::string* output) {
return ReplaceCharsT(input, replace_chars, StringPiece(replace_with), output); return ReplaceCharsT(input, replace_chars, replace_with, output);
} }
bool RemoveChars(const string16& input, bool RemoveChars(const string16& input,
......
...@@ -184,11 +184,11 @@ BASE_EXPORT bool RemoveChars(const std::string& input, ...@@ -184,11 +184,11 @@ BASE_EXPORT bool RemoveChars(const std::string& input,
// NOTE: Safe to use the same variable for both |input| and |output|. // NOTE: Safe to use the same variable for both |input| and |output|.
BASE_EXPORT bool ReplaceChars(const string16& input, BASE_EXPORT bool ReplaceChars(const string16& input,
StringPiece16 replace_chars, StringPiece16 replace_chars,
const string16& replace_with, StringPiece16 replace_with,
string16* output); string16* output);
BASE_EXPORT bool ReplaceChars(const std::string& input, BASE_EXPORT bool ReplaceChars(const std::string& input,
StringPiece replace_chars, StringPiece replace_chars,
const std::string& replace_with, StringPiece replace_with,
std::string* output); std::string* output);
enum TrimPositions { enum TrimPositions {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment