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

Side by Side Diff: core/fxcrt/fx_basic_wstring.cpp

Issue 1846083002: Remove CFX_{Byte,Wide}String::Equal in favor of "==". (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Nits. Created 4 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 unified diff | Download patch
« no previous file with comments | « core/fxcrt/fx_basic_bstring.cpp ('k') | core/fxcrt/include/fx_string.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <cctype> 10 #include <cctype>
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 ConcatInPlace(str.m_pData->m_nDataLength, str.m_pData->m_String); 191 ConcatInPlace(str.m_pData->m_nDataLength, str.m_pData->m_String);
192 return *this; 192 return *this;
193 } 193 }
194 const CFX_WideString& CFX_WideString::operator+=(const CFX_WideStringC& str) { 194 const CFX_WideString& CFX_WideString::operator+=(const CFX_WideStringC& str) {
195 if (str.IsEmpty()) { 195 if (str.IsEmpty()) {
196 return *this; 196 return *this;
197 } 197 }
198 ConcatInPlace(str.GetLength(), str.GetPtr()); 198 ConcatInPlace(str.GetLength(), str.GetPtr());
199 return *this; 199 return *this;
200 } 200 }
201 bool CFX_WideString::Equal(const wchar_t* ptr) const { 201 bool CFX_WideString::operator==(const wchar_t* ptr) const {
202 if (!m_pData) { 202 if (!m_pData)
203 return !ptr || ptr[0] == L'\0'; 203 return !ptr || !ptr[0];
204 } 204
205 if (!ptr) { 205 if (!ptr)
206 return m_pData->m_nDataLength == 0; 206 return m_pData->m_nDataLength == 0;
207 } 207
208 return wcslen(ptr) == static_cast<size_t>(m_pData->m_nDataLength) && 208 return wcslen(ptr) == static_cast<size_t>(m_pData->m_nDataLength) &&
209 wmemcmp(ptr, m_pData->m_String, m_pData->m_nDataLength) == 0; 209 wmemcmp(ptr, m_pData->m_String, m_pData->m_nDataLength) == 0;
210 } 210 }
211 bool CFX_WideString::Equal(const CFX_WideStringC& str) const { 211 bool CFX_WideString::operator==(const CFX_WideStringC& str) const {
212 if (!m_pData) { 212 if (!m_pData)
213 return str.IsEmpty(); 213 return str.IsEmpty();
214 } 214
215 return str.GetLength() == m_pData->m_nDataLength && 215 return str.GetLength() == m_pData->m_nDataLength &&
216 wmemcmp(str.GetPtr(), m_pData->m_String, m_pData->m_nDataLength) == 0; 216 wmemcmp(str.GetPtr(), m_pData->m_String, m_pData->m_nDataLength) == 0;
217 } 217 }
218 bool CFX_WideString::Equal(const CFX_WideString& other) const { 218 bool CFX_WideString::operator==(const CFX_WideString& other) const {
219 if (IsEmpty()) { 219 if (IsEmpty())
220 return other.IsEmpty(); 220 return other.IsEmpty();
221 } 221
222 if (other.IsEmpty()) { 222 if (other.IsEmpty())
223 return false; 223 return false;
224 } 224
225 return other.m_pData->m_nDataLength == m_pData->m_nDataLength && 225 return other.m_pData->m_nDataLength == m_pData->m_nDataLength &&
226 wmemcmp(other.m_pData->m_String, m_pData->m_String, 226 wmemcmp(other.m_pData->m_String, m_pData->m_String,
227 m_pData->m_nDataLength) == 0; 227 m_pData->m_nDataLength) == 0;
228 } 228 }
229 void CFX_WideString::Empty() { 229 void CFX_WideString::Empty() {
230 if (m_pData) { 230 if (m_pData) {
231 m_pData->Release(); 231 m_pData->Release();
232 m_pData = NULL; 232 m_pData = NULL;
233 } 233 }
234 } 234 }
(...skipping 799 matching lines...) Expand 10 before | Expand all | Expand 10 after
1034 int dest_len = 1034 int dest_len =
1035 FXSYS_MultiByteToWideChar(codepage, 0, bstr, src_len, nullptr, 0); 1035 FXSYS_MultiByteToWideChar(codepage, 0, bstr, src_len, nullptr, 0);
1036 CFX_WideString wstr; 1036 CFX_WideString wstr;
1037 if (dest_len) { 1037 if (dest_len) {
1038 FX_WCHAR* dest_buf = wstr.GetBuffer(dest_len); 1038 FX_WCHAR* dest_buf = wstr.GetBuffer(dest_len);
1039 FXSYS_MultiByteToWideChar(codepage, 0, bstr, src_len, dest_buf, dest_len); 1039 FXSYS_MultiByteToWideChar(codepage, 0, bstr, src_len, dest_buf, dest_len);
1040 wstr.ReleaseBuffer(dest_len); 1040 wstr.ReleaseBuffer(dest_len);
1041 } 1041 }
1042 return wstr; 1042 return wstr;
1043 } 1043 }
OLDNEW
« no previous file with comments | « core/fxcrt/fx_basic_bstring.cpp ('k') | core/fxcrt/include/fx_string.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698