Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(516)

Unified Diff: core/src/fxcrt/fx_basic_wstring.cpp

Issue 1127753002: Fix issues with != and == in fx_basic_wstring (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Missing & Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « core/include/fxcrt/fx_string.h ('k') | core/src/fxcrt/fx_basic_wstring_unittest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/src/fxcrt/fx_basic_wstring.cpp
diff --git a/core/src/fxcrt/fx_basic_wstring.cpp b/core/src/fxcrt/fx_basic_wstring.cpp
index 742f249e37d5f523b3c3169e18bf7a8a3d4f41fb..9b27537ed91ac3780ada197c7fe3d3469270c333 100644
--- a/core/src/fxcrt/fx_basic_wstring.cpp
+++ b/core/src/fxcrt/fx_basic_wstring.cpp
@@ -205,41 +205,16 @@ const CFX_WideString& CFX_WideString::operator+=(const CFX_WideStringC& string)
ConcatInPlace(string.GetLength(), string.GetPtr());
return *this;
}
-bool operator==(const CFX_WideString& s1, FX_LPCWSTR s2)
+bool CFX_WideString::Equal(const wchar_t* ptr) const
{
- return s1.Equal(s2);
-}
-bool operator==(FX_LPCWSTR s1, const CFX_WideString& s2)
-{
- return s2.Equal(s1);
-}
-bool operator==(const CFX_WideString& s1, const CFX_WideString& s2)
-{
- return s1.Equal(s2);
-}
-bool operator==(const CFX_WideString& s1, const CFX_WideStringC& s2)
-{
- return s1.Equal(s2);
-}
-bool operator==(const CFX_WideStringC& s1, const CFX_WideString& s2)
-{
- return s2.Equal(s1);
-}
-bool operator != (const CFX_WideString& s1, FX_LPCWSTR s2)
-{
- return !s1.Equal(s2);
-}
-bool operator!=(const CFX_WideString& s1, const CFX_WideString& s2)
-{
- return !s1.Equal(s2);
-}
-bool operator!=(const CFX_WideString& s1, const CFX_WideStringC& s2)
-{
- return !s1.Equal(s2);
-}
-bool operator!=(const CFX_WideStringC& s1, const CFX_WideString& s2)
-{
- return !s2.Equal(s1);
+ if (!m_pData) {
+ return !ptr;
dreamfly912 2015/05/13 09:48:24 Hi, consider this: CFX_WideString left; assert(lef
+ }
+ if (!ptr) {
+ return false;
+ }
+ return wcslen(ptr) == m_pData->m_nDataLength &&
+ wmemcmp(ptr, m_pData->m_String, m_pData->m_nDataLength) == 0;
}
bool CFX_WideString::Equal(const CFX_WideStringC& str) const
{
@@ -247,7 +222,20 @@ bool CFX_WideString::Equal(const CFX_WideStringC& str) const
return str.IsEmpty();
}
return str.GetLength() == m_pData->m_nDataLength &&
- FXSYS_memcmp32(str.GetPtr(), m_pData->m_String, m_pData->m_nDataLength * sizeof(FX_WCHAR)) == 0;
+ wmemcmp(str.GetPtr(), m_pData->m_String, m_pData->m_nDataLength) == 0;
+}
+bool CFX_WideString::Equal(const CFX_WideString& other) const
+{
+ if (!m_pData) {
+ return other.IsEmpty();
+ }
+ if (!other.m_pData) {
+ return false;
+ }
+ return other.m_pData->m_nDataLength == m_pData->m_nDataLength &&
+ wmemcmp(other.m_pData->m_String,
+ m_pData->m_String,
+ m_pData->m_nDataLength) == 0;
}
void CFX_WideString::Empty()
{
« no previous file with comments | « core/include/fxcrt/fx_string.h ('k') | core/src/fxcrt/fx_basic_wstring_unittest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698