Reviewed by Maciej Stachowiak.
authorggaren <ggaren@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 26 Oct 2007 06:55:36 +0000 (06:55 +0000)
committerggaren <ggaren@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 26 Oct 2007 06:55:36 +0000 (06:55 +0000)
        Tweaked the inner hashtable lookup loop to remove a branch in the "not
        found" case. .5% speedup on SunSpider.

        * JavaScriptCore.xcodeproj/project.pbxproj:
        * wtf/HashTable.h:
        (WTF::::lookup):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@27093 268f45cc-cd09-0410-ab3c-d52691b4dbfc

JavaScriptCore/ChangeLog
JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
JavaScriptCore/wtf/HashTable.h

index 3aa3d8281d6a46380db7f0a66ed7680906641995..93ec716dd8f4be9ff808249934b79080ea9523aa 100644 (file)
@@ -1,3 +1,14 @@
+2007-10-25  Geoffrey Garen  <ggaren@apple.com>
+
+        Reviewed by Maciej Stachowiak.
+        
+        Tweaked the inner hashtable lookup loop to remove a branch in the "not 
+        found" case. .5% speedup on SunSpider.
+
+        * JavaScriptCore.xcodeproj/project.pbxproj:
+        * wtf/HashTable.h:
+        (WTF::::lookup):
+
 2007-10-25  Maciej Stachowiak  <mjs@apple.com>
 
         Reviewed by Oliver.
index abc796b521593b1f38a2c6703d9a4729e7e4c874..b96f8e17d7e8187f1777751e86c4c6a7014264dd 100644 (file)
                0867D690FE84028FC02AAC07 /* Project object */ = {
                        isa = PBXProject;
                        buildConfigurationList = 149C277108902AFE008A9EFC /* Build configuration list for PBXProject "JavaScriptCore" */;
+                       compatibilityVersion = "Xcode 2.4";
                        hasScannedForEncodings = 1;
                        mainGroup = 0867D691FE84028FC02AAC07 /* JavaScriptCore */;
                        productRefGroup = 034768DFFF38A50411DB9C8B /* Products */;
index 550d981e4486de57d73ad944e067e3393427f17d..4d7f98acb5b4cb07fec1b31aecaa7859af1a8281 100644 (file)
@@ -396,14 +396,20 @@ namespace WTF {
         int probeCount = 0;
 #endif
 
-        ValueType *table = m_table;
-        ValueType *entry;
-        ValueType *deletedEntry = 0;
-        while (!isEmptyBucket(*(entry = table + i))) {
+        ValueType* table = m_table;
+        ValueType* deletedEntry = 0;
+
+        while (1) {
+            ValueType* entry = table + i;
+
+            if (isEmptyBucket(*entry))
+                return makeLookupResult(deletedEntry ? deletedEntry : entry, false, h);
+            
             if (isDeletedBucket(*entry))
                 deletedEntry = entry;
             else if (HashTranslator::equal(Extractor::extract(*entry), key))
                 return makeLookupResult(entry, true, h);
+
 #if DUMP_HASHTABLE_STATS
             ++probeCount;
             HashTableStats::recordCollisionAtCount(probeCount);
@@ -412,11 +418,8 @@ namespace WTF {
                 k = 1 | (h % sizeMask);
             i = (i + k) & sizeMask;
         }
-
-        return makeLookupResult(deletedEntry ? deletedEntry : entry, false, h);
     }
 
-
     template<typename Key, typename Value, typename Extractor, typename HashFunctions, typename Traits, typename KeyTraits>
     template<typename T, typename Extra, typename HashTranslator>
     inline pair<typename HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits>::iterator, bool> HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits>::add(const T& key, const Extra &extra)