diff options
author | deanm@chromium.org <deanm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-05 14:11:09 +0000 |
---|---|---|
committer | deanm@chromium.org <deanm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-05 14:11:09 +0000 |
commit | fa34a7a36eef3100f3de056ebe79cb55fd62cf09 (patch) | |
tree | 4fc785edc17fcd563265ddef9a6e3df762b4208c /base | |
parent | 3347870323d0366168c1ddf11a484b30207bea05 (diff) | |
download | chromium_src-fa34a7a36eef3100f3de056ebe79cb55fd62cf09.zip chromium_src-fa34a7a36eef3100f3de056ebe79cb55fd62cf09.tar.gz chromium_src-fa34a7a36eef3100f3de056ebe79cb55fd62cf09.tar.bz2 |
Make UTF8ToWide take a StringPiece, to avoid copying to a std::string.
The previous prototype took only a std::string, unless you used the less convenient output parameter version. This required copying char* input to a std::string. Using a StringPiece the input will be implicitly both std::string and char* without any copying. This helps especially on Linux, where all input we get will be in utf8 char*.
Review URL: http://codereview.chromium.org/40106
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10985 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r-- | base/string_util.h | 3 | ||||
-rw-r--r-- | base/string_util_icu.cc | 2 |
2 files changed, 3 insertions, 2 deletions
diff --git a/base/string_util.h b/base/string_util.h index a688828..7f86009 100644 --- a/base/string_util.h +++ b/base/string_util.h @@ -14,6 +14,7 @@ #include "base/basictypes.h" #include "base/string16.h" +#include "base/string_piece.h" // For implicit conversions. // Safe standard library wrappers for all platforms. @@ -186,7 +187,7 @@ string16 ASCIIToUTF16(const std::string& ascii); bool WideToUTF8(const wchar_t* src, size_t src_len, std::string* output); std::string WideToUTF8(const std::wstring& wide); bool UTF8ToWide(const char* src, size_t src_len, std::wstring* output); -std::wstring UTF8ToWide(const std::string& utf8); +std::wstring UTF8ToWide(const StringPiece& utf8); bool WideToUTF16(const wchar_t* src, size_t src_len, string16* output); string16 WideToUTF16(const std::wstring& wide); diff --git a/base/string_util_icu.cc b/base/string_util_icu.cc index eae66d1..4debcca 100644 --- a/base/string_util_icu.cc +++ b/base/string_util_icu.cc @@ -198,7 +198,7 @@ bool WideToUTF8(const wchar_t* src, size_t src_len, std::string* output) { return ConvertUnicode<wchar_t, std::string>(src, src_len, output); } -std::wstring UTF8ToWide(const std::string& utf8) { +std::wstring UTF8ToWide(const StringPiece& utf8) { std::wstring ret; if (utf8.empty()) return ret; |