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

Side by Side Diff: third_party/WebKit/Source/wtf/text/StringBuilder.h

Issue 1807853003: Deprecate some macros in wtf/Assertions.h in favor of base/logging.h (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 9 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009, 2010, 2012, 2013 Apple Inc. All rights reserved. 2 * Copyright (C) 2009, 2010, 2012, 2013 Apple Inc. All rights reserved.
3 * Copyright (C) 2012 Google Inc. All rights reserved. 3 * Copyright (C) 2012 Google Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 // If the buffer is sufficiently over-allocated, make a new AtomicString from a copy so its buffer is not so large. 200 // If the buffer is sufficiently over-allocated, make a new AtomicString from a copy so its buffer is not so large.
201 if (canShrink()) { 201 if (canShrink()) {
202 if (is8Bit()) 202 if (is8Bit())
203 return AtomicString(characters8(), length()); 203 return AtomicString(characters8(), length());
204 return AtomicString(characters16(), length()); 204 return AtomicString(characters16(), length());
205 } 205 }
206 206
207 if (!m_string.isNull()) 207 if (!m_string.isNull())
208 return AtomicString(m_string); 208 return AtomicString(m_string);
209 209
210 ASSERT(m_buffer); 210 DCHECK(m_buffer);
211 return AtomicString(m_buffer.get(), 0, m_length); 211 return AtomicString(m_buffer.get(), 0, m_length);
212 } 212 }
213 213
214 unsigned length() const 214 unsigned length() const
215 { 215 {
216 return m_length; 216 return m_length;
217 } 217 }
218 218
219 bool isEmpty() const { return !m_length; } 219 bool isEmpty() const { return !m_length; }
220 220
(...skipping 13 matching lines...) Expand all
234 UChar operator[](unsigned i) const 234 UChar operator[](unsigned i) const
235 { 235 {
236 ASSERT_WITH_SECURITY_IMPLICATION(i < m_length); 236 ASSERT_WITH_SECURITY_IMPLICATION(i < m_length);
237 if (m_is8Bit) 237 if (m_is8Bit)
238 return characters8()[i]; 238 return characters8()[i];
239 return characters16()[i]; 239 return characters16()[i];
240 } 240 }
241 241
242 const LChar* characters8() const 242 const LChar* characters8() const
243 { 243 {
244 ASSERT(m_is8Bit); 244 DCHECK(m_is8Bit);
245 if (!m_length) 245 if (!m_length)
246 return 0; 246 return 0;
247 if (!m_string.isNull()) 247 if (!m_string.isNull())
248 return m_string.characters8(); 248 return m_string.characters8();
249 ASSERT(m_buffer); 249 DCHECK(m_buffer);
250 return m_buffer->characters8(); 250 return m_buffer->characters8();
251 } 251 }
252 252
253 const UChar* characters16() const 253 const UChar* characters16() const
254 { 254 {
255 ASSERT(!m_is8Bit); 255 DCHECK(!m_is8Bit);
256 if (!m_length) 256 if (!m_length)
257 return 0; 257 return 0;
258 if (!m_string.isNull()) 258 if (!m_string.isNull())
259 return m_string.characters16(); 259 return m_string.characters16();
260 ASSERT(m_buffer); 260 DCHECK(m_buffer);
261 return m_buffer->characters16(); 261 return m_buffer->characters16();
262 } 262 }
263 263
264 bool is8Bit() const { return m_is8Bit; } 264 bool is8Bit() const { return m_is8Bit; }
265 265
266 void clear() 266 void clear()
267 { 267 {
268 m_length = 0; 268 m_length = 0;
269 m_string = String(); 269 m_string = String();
270 m_buffer = nullptr; 270 m_buffer = nullptr;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 LChar* m_bufferCharacters8; 302 LChar* m_bufferCharacters8;
303 UChar* m_bufferCharacters16; 303 UChar* m_bufferCharacters16;
304 }; 304 };
305 unsigned m_length; 305 unsigned m_length;
306 bool m_is8Bit; 306 bool m_is8Bit;
307 }; 307 };
308 308
309 template <> 309 template <>
310 ALWAYS_INLINE LChar* StringBuilder::getBufferCharacters<LChar>() 310 ALWAYS_INLINE LChar* StringBuilder::getBufferCharacters<LChar>()
311 { 311 {
312 ASSERT(m_is8Bit); 312 DCHECK(m_is8Bit);
313 return m_bufferCharacters8; 313 return m_bufferCharacters8;
314 } 314 }
315 315
316 template <> 316 template <>
317 ALWAYS_INLINE UChar* StringBuilder::getBufferCharacters<UChar>() 317 ALWAYS_INLINE UChar* StringBuilder::getBufferCharacters<UChar>()
318 { 318 {
319 ASSERT(!m_is8Bit); 319 DCHECK(!m_is8Bit);
320 return m_bufferCharacters16; 320 return m_bufferCharacters16;
321 } 321 }
322 322
323 template <typename CharType> 323 template <typename CharType>
324 bool equal(const StringBuilder& s, const CharType* buffer, unsigned length) 324 bool equal(const StringBuilder& s, const CharType* buffer, unsigned length)
325 { 325 {
326 if (s.length() != length) 326 if (s.length() != length)
327 return false; 327 return false;
328 328
329 if (s.is8Bit()) 329 if (s.is8Bit())
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 inline bool operator==(const StringBuilder& a, const String& b) { return equal(a , b); } 394 inline bool operator==(const StringBuilder& a, const String& b) { return equal(a , b); }
395 inline bool operator!=(const StringBuilder& a, const String& b) { return !equal( a, b); } 395 inline bool operator!=(const StringBuilder& a, const String& b) { return !equal( a, b); }
396 inline bool operator==(const String& a, const StringBuilder& b) { return equal(b , a); } 396 inline bool operator==(const String& a, const StringBuilder& b) { return equal(b , a); }
397 inline bool operator!=(const String& a, const StringBuilder& b) { return !equal( b, a); } 397 inline bool operator!=(const String& a, const StringBuilder& b) { return !equal( b, a); }
398 398
399 } // namespace WTF 399 } // namespace WTF
400 400
401 using WTF::StringBuilder; 401 using WTF::StringBuilder;
402 402
403 #endif // StringBuilder_h 403 #endif // StringBuilder_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698