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

Side by Side Diff: Source/wtf/text/AtomicString.cpp

Issue 17045008: HashSet: reverse the order of the template arguments at alternate 'find', 'contains' and 'add' meth… (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 6 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 | « Source/wtf/HashSet.h ('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 /* 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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 WTFThreadData& data = wtfThreadData(); 69 WTFThreadData& data = wtfThreadData();
70 AtomicStringTable* table = data.atomicStringTable(); 70 AtomicStringTable* table = data.atomicStringTable();
71 if (UNLIKELY(!table)) 71 if (UNLIKELY(!table))
72 table = AtomicStringTable::create(data); 72 table = AtomicStringTable::create(data);
73 return table->table(); 73 return table->table();
74 } 74 }
75 75
76 template<typename T, typename HashTranslator> 76 template<typename T, typename HashTranslator>
77 static inline PassRefPtr<StringImpl> addToStringTable(const T& value) 77 static inline PassRefPtr<StringImpl> addToStringTable(const T& value)
78 { 78 {
79 HashSet<StringImpl*>::AddResult addResult = stringTable().add<T, HashTransla tor>(value); 79 HashSet<StringImpl*>::AddResult addResult = stringTable().add<HashTranslator >(value);
80 80
81 // If the string is newly-translated, then we need to adopt it. 81 // If the string is newly-translated, then we need to adopt it.
82 // The boolean in the pair tells us if that is so. 82 // The boolean in the pair tells us if that is so.
83 return addResult.isNewEntry ? adoptRef(*addResult.iterator) : *addResult.ite rator; 83 return addResult.isNewEntry ? adoptRef(*addResult.iterator) : *addResult.ite rator;
84 } 84 }
85 85
86 struct CStringTranslator { 86 struct CStringTranslator {
87 static unsigned hash(const LChar* c) 87 static unsigned hash(const LChar* c)
88 { 88 {
89 return StringHasher::computeHashAndMaskTop8Bits(c); 89 return StringHasher::computeHashAndMaskTop8Bits(c);
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 if (result == r) 387 if (result == r)
388 r->setIsAtomic(true); 388 r->setIsAtomic(true);
389 ASSERT(!r->isStatic() || result->isStatic()); 389 ASSERT(!r->isStatic() || result->isStatic());
390 return result; 390 return result;
391 } 391 }
392 392
393 template<typename CharacterType> 393 template<typename CharacterType>
394 static inline HashSet<StringImpl*>::iterator findString(const StringImpl* string Impl) 394 static inline HashSet<StringImpl*>::iterator findString(const StringImpl* string Impl)
395 { 395 {
396 HashAndCharacters<CharacterType> buffer = { stringImpl->existingHash(), stri ngImpl->getCharacters<CharacterType>(), stringImpl->length() }; 396 HashAndCharacters<CharacterType> buffer = { stringImpl->existingHash(), stri ngImpl->getCharacters<CharacterType>(), stringImpl->length() };
397 return stringTable().find<HashAndCharacters<CharacterType>, HashAndCharacter sTranslator<CharacterType> >(buffer); 397 return stringTable().find<HashAndCharactersTranslator<CharacterType> >(buffe r);
398 } 398 }
399 399
400 AtomicStringImpl* AtomicString::find(const StringImpl* stringImpl) 400 AtomicStringImpl* AtomicString::find(const StringImpl* stringImpl)
401 { 401 {
402 ASSERT(stringImpl); 402 ASSERT(stringImpl);
403 ASSERT(stringImpl->existingHash()); 403 ASSERT(stringImpl->existingHash());
404 404
405 if (!stringImpl->length()) 405 if (!stringImpl->length())
406 return static_cast<AtomicStringImpl*>(StringImpl::empty()); 406 return static_cast<AtomicStringImpl*>(StringImpl::empty());
407 407
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 } 453 }
454 454
455 #ifndef NDEBUG 455 #ifndef NDEBUG
456 void AtomicString::show() const 456 void AtomicString::show() const
457 { 457 {
458 m_string.show(); 458 m_string.show();
459 } 459 }
460 #endif 460 #endif
461 461
462 } // namespace WTF 462 } // namespace WTF
OLDNEW
« no previous file with comments | « Source/wtf/HashSet.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698