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

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

Issue 2338623005: Add check for trivial string equality (Closed)
Patch Set: Created 4 years, 3 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') | no next file » | 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 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 173
174 bool CFX_WideString::operator==(const CFX_WideStringC& str) const { 174 bool CFX_WideString::operator==(const CFX_WideStringC& str) const {
175 if (!m_pData) 175 if (!m_pData)
176 return str.IsEmpty(); 176 return str.IsEmpty();
177 177
178 return m_pData->m_nDataLength == str.GetLength() && 178 return m_pData->m_nDataLength == str.GetLength() &&
179 wmemcmp(m_pData->m_String, str.c_str(), str.GetLength()) == 0; 179 wmemcmp(m_pData->m_String, str.c_str(), str.GetLength()) == 0;
180 } 180 }
181 181
182 bool CFX_WideString::operator==(const CFX_WideString& other) const { 182 bool CFX_WideString::operator==(const CFX_WideString& other) const {
183 if (m_pData == other.m_pData)
184 return true;
185
183 if (IsEmpty()) 186 if (IsEmpty())
184 return other.IsEmpty(); 187 return other.IsEmpty();
185 188
186 if (other.IsEmpty()) 189 if (other.IsEmpty())
187 return false; 190 return false;
188 191
189 return other.m_pData->m_nDataLength == m_pData->m_nDataLength && 192 return other.m_pData->m_nDataLength == m_pData->m_nDataLength &&
190 wmemcmp(other.m_pData->m_String, m_pData->m_String, 193 wmemcmp(other.m_pData->m_String, m_pData->m_String,
191 m_pData->m_nDataLength) == 0; 194 m_pData->m_nDataLength) == 0;
192 } 195 }
(...skipping 807 matching lines...) Expand 10 before | Expand all | Expand 10 after
1000 FXSYS_MultiByteToWideChar(codepage, 0, bstr.c_str(), src_len, nullptr, 0); 1003 FXSYS_MultiByteToWideChar(codepage, 0, bstr.c_str(), src_len, nullptr, 0);
1001 CFX_WideString wstr; 1004 CFX_WideString wstr;
1002 if (dest_len) { 1005 if (dest_len) {
1003 FX_WCHAR* dest_buf = wstr.GetBuffer(dest_len); 1006 FX_WCHAR* dest_buf = wstr.GetBuffer(dest_len);
1004 FXSYS_MultiByteToWideChar(codepage, 0, bstr.c_str(), src_len, dest_buf, 1007 FXSYS_MultiByteToWideChar(codepage, 0, bstr.c_str(), src_len, dest_buf,
1005 dest_len); 1008 dest_len);
1006 wstr.ReleaseBuffer(dest_len); 1009 wstr.ReleaseBuffer(dest_len);
1007 } 1010 }
1008 return wstr; 1011 return wstr;
1009 } 1012 }
OLDNEW
« no previous file with comments | « core/fxcrt/fx_basic_bstring.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698