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

Side by Side Diff: core/fxcrt/fx_basic_bstring.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 | « no previous file | core/fxcrt/fx_basic_wstring.cpp » ('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 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 195
196 bool CFX_ByteString::operator==(const CFX_ByteStringC& str) const { 196 bool CFX_ByteString::operator==(const CFX_ByteStringC& str) const {
197 if (!m_pData) 197 if (!m_pData)
198 return str.IsEmpty(); 198 return str.IsEmpty();
199 199
200 return m_pData->m_nDataLength == str.GetLength() && 200 return m_pData->m_nDataLength == str.GetLength() &&
201 FXSYS_memcmp(m_pData->m_String, str.c_str(), str.GetLength()) == 0; 201 FXSYS_memcmp(m_pData->m_String, str.c_str(), str.GetLength()) == 0;
202 } 202 }
203 203
204 bool CFX_ByteString::operator==(const CFX_ByteString& other) const { 204 bool CFX_ByteString::operator==(const CFX_ByteString& other) const {
205 if (m_pData == other.m_pData)
206 return true;
207
205 if (IsEmpty()) 208 if (IsEmpty())
206 return other.IsEmpty(); 209 return other.IsEmpty();
207 210
208 if (other.IsEmpty()) 211 if (other.IsEmpty())
209 return false; 212 return false;
210 213
211 return other.m_pData->m_nDataLength == m_pData->m_nDataLength && 214 return other.m_pData->m_nDataLength == m_pData->m_nDataLength &&
212 FXSYS_memcmp(other.m_pData->m_String, m_pData->m_String, 215 FXSYS_memcmp(other.m_pData->m_String, m_pData->m_String,
213 m_pData->m_nDataLength) == 0; 216 m_pData->m_nDataLength) == 0;
214 } 217 }
(...skipping 773 matching lines...) Expand 10 before | Expand all | Expand 10 after
988 fraction %= scale; 991 fraction %= scale;
989 scale /= 10; 992 scale /= 10;
990 } 993 }
991 return buf_size; 994 return buf_size;
992 } 995 }
993 CFX_ByteString CFX_ByteString::FormatFloat(FX_FLOAT d, int precision) { 996 CFX_ByteString CFX_ByteString::FormatFloat(FX_FLOAT d, int precision) {
994 FX_CHAR buf[32]; 997 FX_CHAR buf[32];
995 FX_STRSIZE len = FX_ftoa(d, buf); 998 FX_STRSIZE len = FX_ftoa(d, buf);
996 return CFX_ByteString(buf, len); 999 return CFX_ByteString(buf, len);
997 } 1000 }
OLDNEW
« no previous file with comments | « no previous file | core/fxcrt/fx_basic_wstring.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698