diff options
author | tsepez <tsepez@chromium.org> | 2016-09-15 11:55:00 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-09-15 11:55:00 -0700 |
commit | 8f53f54a9ccada2ea8651f2786f1bbee323f09b7 (patch) | |
tree | e5592afacbaa9e862c0934549faf908bb100c5bd /core/fxcrt/fx_basic_wstring.cpp | |
parent | 38fd84428a1ea007a043be0b7d9b289e47aa5da0 (diff) | |
download | pdfium-8f53f54a9ccada2ea8651f2786f1bbee323f09b7.tar.xz |
Add short-cut in CFX_{Byte,Wide}String::Operator<()
Strings are never less than themselves, and this will occur given
the shared CoW nature of these strings.
Review-Url: https://codereview.chromium.org/2347433004
Diffstat (limited to 'core/fxcrt/fx_basic_wstring.cpp')
-rw-r--r-- | core/fxcrt/fx_basic_wstring.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/core/fxcrt/fx_basic_wstring.cpp b/core/fxcrt/fx_basic_wstring.cpp index 88fc588947..29e915f30c 100644 --- a/core/fxcrt/fx_basic_wstring.cpp +++ b/core/fxcrt/fx_basic_wstring.cpp @@ -194,6 +194,15 @@ bool CFX_WideString::operator==(const CFX_WideString& other) const { m_pData->m_nDataLength) == 0; } +bool CFX_WideString::operator<(const CFX_WideString& str) const { + if (m_pData == str.m_pData) + return false; + + int result = + wmemcmp(c_str(), str.c_str(), std::min(GetLength(), str.GetLength())); + return result < 0 || (result == 0 && GetLength() < str.GetLength()); +} + void CFX_WideString::AssignCopy(const FX_WCHAR* pSrcData, FX_STRSIZE nSrcLen) { AllocBeforeWrite(nSrcLen); m_pData->CopyContents(pSrcData, nSrcLen); |