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

Unified Diff: Source/wtf/HashTable.h

Issue 117123003: Inline HashTable::find() methods for performance (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Remove other unnecessary null check Created 7 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/wtf/HashTable.h
diff --git a/Source/wtf/HashTable.h b/Source/wtf/HashTable.h
index d88038b65f7d37f38f0bfc9b2424ce492792f5b5..9b195d863dcceb4640e47ba739deb3258456a825 100644
--- a/Source/wtf/HashTable.h
+++ b/Source/wtf/HashTable.h
@@ -451,15 +451,15 @@ namespace WTF {
template<typename HashTranslator, typename T>
inline Value* HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits, Allocator>::lookup(const T& key)
{
+ ValueType* table = m_table;
+ if (!table)
+ return 0;
+
int k = 0;
int sizeMask = m_tableSizeMask;
- ValueType* table = m_table;
unsigned h = HashTranslator::hash(key);
int i = h & sizeMask;
- if (!table)
- return 0;
-
#if DUMP_HASHTABLE_STATS
atomicIncrement(&HashTableStats::numAccesses);
int probeCount = 0;
@@ -795,11 +795,8 @@ namespace WTF {
template<typename Key, typename Value, typename Extractor, typename HashFunctions, typename Traits, typename KeyTraits, typename Allocator>
template <typename HashTranslator, typename T>
- typename HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits, Allocator>::iterator HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits, Allocator>::find(const T& key)
+ inline typename HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits, Allocator>::iterator HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits, Allocator>::find(const T& key)
{
- if (!m_table)
- return end();
-
ValueType* entry = lookup<HashTranslator>(key);
if (!entry)
return end();
@@ -809,11 +806,8 @@ namespace WTF {
template<typename Key, typename Value, typename Extractor, typename HashFunctions, typename Traits, typename KeyTraits, typename Allocator>
template <typename HashTranslator, typename T>
- typename HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits, Allocator>::const_iterator HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits, Allocator>::find(const T& key) const
+ inline typename HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits, Allocator>::const_iterator HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits, Allocator>::find(const T& key) const
{
- if (!m_table)
- return end();
-
ValueType* entry = const_cast<HashTable*>(this)->lookup<HashTranslator>(key);
if (!entry)
return end();
@@ -825,9 +819,6 @@ namespace WTF {
template <typename HashTranslator, typename T>
bool HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits, Allocator>::contains(const T& key) const
{
- if (!m_table)
- return false;
-
return const_cast<HashTable*>(this)->lookup<HashTranslator>(key);
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698