diff options
author | tsepez <tsepez@chromium.org> | 2016-04-08 09:00:35 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-04-08 09:00:35 -0700 |
commit | 8b36e5cc3d5f5f579c6b060e2c40b896a4b02bc0 (patch) | |
tree | f84a20d330d92b791d0322f424cb155816d77d1b /core/fxcrt/fx_basic_wstring.cpp | |
parent | 8da140e8747920057a2f2bbcf5c78e40bb198733 (diff) | |
download | pdfium-8b36e5cc3d5f5f579c6b060e2c40b896a4b02bc0.tar.xz |
Make CFX_WideString::FromLocal() take a CFX_ByteStringC arg
It doesn't persist the string beyond the duration of the
call, hence it should take the *StringC variant. Doing so
avoids some allocs by changing to the *StringC ctor in a few
places, at the cost of some explicit .ToByteStringC() calls
(which are cheap).
Review URL: https://codereview.chromium.org/1862953004
Diffstat (limited to 'core/fxcrt/fx_basic_wstring.cpp')
-rw-r--r-- | core/fxcrt/fx_basic_wstring.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/core/fxcrt/fx_basic_wstring.cpp b/core/fxcrt/fx_basic_wstring.cpp index e2e122be9a..b5ccaf6da5 100644 --- a/core/fxcrt/fx_basic_wstring.cpp +++ b/core/fxcrt/fx_basic_wstring.cpp @@ -747,12 +747,12 @@ void CFX_WideString::SetAt(FX_STRSIZE nIndex, FX_WCHAR ch) { } // static -CFX_WideString CFX_WideString::FromLocal(const CFX_ByteString& str) { +CFX_WideString CFX_WideString::FromLocal(const CFX_ByteStringC& str) { return FromCodePage(str, 0); } // static -CFX_WideString CFX_WideString::FromCodePage(const CFX_ByteString& str, +CFX_WideString CFX_WideString::FromCodePage(const CFX_ByteStringC& str, uint16_t codepage) { return CFX_CharMap::GetWideString(codepage, str); } @@ -943,7 +943,7 @@ FX_FLOAT CFX_WideString::GetFloat() const { // static CFX_ByteString CFX_CharMap::GetByteString(uint16_t codepage, - const CFX_WideString& wstr) { + const CFX_WideStringC& wstr) { FXSYS_assert(IsValidCodePage(codepage)); int src_len = wstr.GetLength(); int dest_len = FXSYS_WideCharToMultiByte(codepage, 0, wstr.c_str(), src_len, @@ -960,15 +960,16 @@ CFX_ByteString CFX_CharMap::GetByteString(uint16_t codepage, // static CFX_WideString CFX_CharMap::GetWideString(uint16_t codepage, - const CFX_ByteString& bstr) { + const CFX_ByteStringC& bstr) { FXSYS_assert(IsValidCodePage(codepage)); int src_len = bstr.GetLength(); int dest_len = - FXSYS_MultiByteToWideChar(codepage, 0, bstr, src_len, nullptr, 0); + FXSYS_MultiByteToWideChar(codepage, 0, bstr.c_str(), src_len, nullptr, 0); CFX_WideString wstr; if (dest_len) { FX_WCHAR* dest_buf = wstr.GetBuffer(dest_len); - FXSYS_MultiByteToWideChar(codepage, 0, bstr, src_len, dest_buf, dest_len); + FXSYS_MultiByteToWideChar(codepage, 0, bstr.c_str(), src_len, dest_buf, + dest_len); wstr.ReleaseBuffer(dest_len); } return wstr; |