Chromium Code Reviews| Index: core/src/fxcrt/fx_basic_bstring.cpp |
| diff --git a/core/src/fxcrt/fx_basic_bstring.cpp b/core/src/fxcrt/fx_basic_bstring.cpp |
| index e0d1146068f703909814fcf5cc2fd7eb66c3e0b7..85e504109574ad6c511af8d85c0b8511c48e68c4 100644 |
| --- a/core/src/fxcrt/fx_basic_bstring.cpp |
| +++ b/core/src/fxcrt/fx_basic_bstring.cpp |
| @@ -910,25 +910,20 @@ CFX_WideString CFX_ByteString::UTF8Decode() const { |
| } |
| return decoder.GetResult(); |
| } |
| + |
| +// static |
| CFX_ByteString CFX_ByteString::FromUnicode(const FX_WCHAR* str, |
| FX_STRSIZE len) { |
| - if (len < 0) { |
| - len = FXSYS_wcslen(str); |
| - } |
| - CFX_ByteString bstr; |
| - bstr.ConvertFrom(CFX_WideString(str, len)); |
| - return bstr; |
| + FX_STRSIZE str_len = len >= 0 ? len : FXSYS_wcslen(str); |
|
Tom Sepez
2016/02/19 17:02:47
Follow-up: the len == -1 convention for unknown le
Lei Zhang
2016/02/19 18:48:34
There's a ton of these in the code base. Probably
|
| + return FromUnicode(CFX_WideString(str, str_len)); |
| } |
| + |
| +// static |
| CFX_ByteString CFX_ByteString::FromUnicode(const CFX_WideString& str) { |
| - return FromUnicode(str.c_str(), str.GetLength()); |
| -} |
| -void CFX_ByteString::ConvertFrom(const CFX_WideString& str, |
| - CFX_CharMap* pCharMap) { |
| - if (!pCharMap) { |
| - pCharMap = CFX_CharMap::GetDefaultMapper(); |
| - } |
| - *this = (*pCharMap->m_GetByteString)(pCharMap, str); |
| + CFX_CharMap* pCharMap = CFX_CharMap::GetDefaultMapper(); |
| + return (*pCharMap->m_GetByteString)(pCharMap, str); |
| } |
| + |
| int CFX_ByteString::Compare(const CFX_ByteStringC& str) const { |
| if (!m_pData) { |
| return str.IsEmpty() ? 0 : -1; |