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

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

Issue 1125703004: Fix issuse with != and == shown by fx_basic_bstring unit tests. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Tidy, avoid typedefs to improve transparency. 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_bstring_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_bstring.cpp
diff --git a/core/src/fxcrt/fx_basic_bstring.cpp b/core/src/fxcrt/fx_basic_bstring.cpp
index 9cf084c2fbc77fc980a2a0ec45f5bde3385d7eee..f18ae0825c90270e1e11d1645594f5745a640d4a 100644
--- a/core/src/fxcrt/fx_basic_bstring.cpp
+++ b/core/src/fxcrt/fx_basic_bstring.cpp
@@ -251,24 +251,37 @@ const CFX_ByteString& CFX_ByteString::operator+=(FX_BSTR string)
ConcatInPlace(string.GetLength(), string.GetCStr());
return *this;
}
-bool CFX_ByteString::Equal(FX_BSTR str) const
+bool CFX_ByteString::Equal(const char* ptr) const
+{
+ if (!m_pData) {
+ return !ptr;
+ }
+ if (!ptr) {
+ return false;
+ }
+ return strlen(ptr) == m_pData->m_nDataLength &&
+ FXSYS_memcmp32(ptr, m_pData->m_String, m_pData->m_nDataLength) == 0;
+}
+bool CFX_ByteString::Equal(const CFX_ByteStringC& str) const
{
if (m_pData == NULL) {
return str.IsEmpty();
}
return m_pData->m_nDataLength == str.GetLength() &&
- FXSYS_memcmp32(m_pData->m_String, str.GetCStr(), str.GetLength()) == 0;
+ FXSYS_memcmp32(m_pData->m_String, str.GetCStr(), str.GetLength()) == 0;
}
-bool CFX_ByteString::operator ==(const CFX_ByteString& s2) const
+bool CFX_ByteString::Equal(const CFX_ByteString& other) const
{
- if (m_pData == NULL) {
- return s2.IsEmpty();
+ if (!m_pData) {
+ return other.IsEmpty();
}
- if (s2.m_pData == NULL) {
+ if (!other.m_pData) {
return false;
}
- return m_pData->m_nDataLength == s2.m_pData->m_nDataLength &&
- FXSYS_memcmp32(m_pData->m_String, s2.m_pData->m_String, m_pData->m_nDataLength) == 0;
+ return other.m_pData->m_nDataLength == m_pData->m_nDataLength &&
+ FXSYS_memcmp32(other.m_pData->m_String,
+ m_pData->m_String,
+ m_pData->m_nDataLength) == 0;
}
void CFX_ByteString::Empty()
{
« no previous file with comments | « core/include/fxcrt/fx_string.h ('k') | core/src/fxcrt/fx_basic_bstring_unittest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698