OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2013 Apple Inc. All rights reserv
ed. | 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2013 Apple Inc. All rights reserv
ed. |
3 * Copyright (C) 2010 Patrick Gansterer <paroga@paroga.com> | 3 * Copyright (C) 2010 Patrick Gansterer <paroga@paroga.com> |
4 * Copyright (C) 2012 Google Inc. All rights reserved. | 4 * Copyright (C) 2012 Google Inc. All rights reserved. |
5 * | 5 * |
6 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
7 * modify it under the terms of the GNU Library General Public | 7 * modify it under the terms of the GNU Library General Public |
8 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
9 * version 2 of the License, or (at your option) any later version. | 9 * version 2 of the License, or (at your option) any later version. |
10 * | 10 * |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 } | 236 } |
237 }; | 237 }; |
238 | 238 |
239 PassRefPtr<StringImpl> AtomicString::add(const UChar* s, unsigned length) | 239 PassRefPtr<StringImpl> AtomicString::add(const UChar* s, unsigned length) |
240 { | 240 { |
241 if (!s) | 241 if (!s) |
242 return 0; | 242 return 0; |
243 | 243 |
244 if (!length) | 244 if (!length) |
245 return StringImpl::empty(); | 245 return StringImpl::empty(); |
246 | 246 |
247 UCharBuffer buffer = { s, length }; | 247 UCharBuffer buffer = { s, length }; |
248 return addToStringTable<UCharBuffer, UCharBufferTranslator>(buffer); | 248 return addToStringTable<UCharBuffer, UCharBufferTranslator>(buffer); |
249 } | 249 } |
250 | 250 |
251 PassRefPtr<StringImpl> AtomicString::add(const UChar* s, unsigned length, unsign
ed existingHash) | 251 PassRefPtr<StringImpl> AtomicString::add(const UChar* s, unsigned length, unsign
ed existingHash) |
252 { | 252 { |
253 ASSERT(s); | 253 ASSERT(s); |
254 ASSERT(existingHash); | 254 ASSERT(existingHash); |
255 | 255 |
256 if (!length) | 256 if (!length) |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 unsigned maxLength = baseString->length() - start; | 316 unsigned maxLength = baseString->length() - start; |
317 if (length >= maxLength) { | 317 if (length >= maxLength) { |
318 if (!start) | 318 if (!start) |
319 return add(baseString); | 319 return add(baseString); |
320 length = maxLength; | 320 length = maxLength; |
321 } | 321 } |
322 | 322 |
323 SubstringLocation buffer = { baseString, start, length }; | 323 SubstringLocation buffer = { baseString, start, length }; |
324 return addToStringTable<SubstringLocation, SubstringTranslator>(buffer); | 324 return addToStringTable<SubstringLocation, SubstringTranslator>(buffer); |
325 } | 325 } |
326 | 326 |
327 typedef HashTranslatorCharBuffer<LChar> LCharBuffer; | 327 typedef HashTranslatorCharBuffer<LChar> LCharBuffer; |
328 struct LCharBufferTranslator { | 328 struct LCharBufferTranslator { |
329 static unsigned hash(const LCharBuffer& buf) | 329 static unsigned hash(const LCharBuffer& buf) |
330 { | 330 { |
331 return StringHasher::computeHashAndMaskTop8Bits(buf.s, buf.length); | 331 return StringHasher::computeHashAndMaskTop8Bits(buf.s, buf.length); |
332 } | 332 } |
333 | 333 |
334 static bool equal(StringImpl* const& str, const LCharBuffer& buf) | 334 static bool equal(StringImpl* const& str, const LCharBuffer& buf) |
335 { | 335 { |
336 return WTF::equal(str, buf.s, buf.length); | 336 return WTF::equal(str, buf.s, buf.length); |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
460 } | 460 } |
461 | 461 |
462 #ifndef NDEBUG | 462 #ifndef NDEBUG |
463 void AtomicString::show() const | 463 void AtomicString::show() const |
464 { | 464 { |
465 m_string.show(); | 465 m_string.show(); |
466 } | 466 } |
467 #endif | 467 #endif |
468 | 468 |
469 } // namespace WTF | 469 } // namespace WTF |
OLD | NEW |