Bug 800481 - Remove unnecessary second arg from HashTable::hash{1,2}. r=luke.
authorNicholas Nethercote <nnethercote@mozilla.com>
Thu, 11 Oct 2012 16:36:29 -0700
changeset 110134 0bf4db8c014cef1ea9282d8ca126800d4e85f850
parent 110133 a315b2dfd1b26a7e6153150ae4faa9eb5d720612
child 110135 31bfd182d836781b59b4f4aad787c29a8606f4c4
push id93
push usernmatsakis@mozilla.com
push dateWed, 31 Oct 2012 21:26:57 +0000
reviewersluke
bugs800481
milestone19.0a1
Bug 800481 - Remove unnecessary second arg from HashTable::hash{1,2}. r=luke.
js/public/HashTable.h
--- a/js/public/HashTable.h
+++ b/js/public/HashTable.h
@@ -383,26 +383,26 @@ class HashTable : private AllocPolicy
 
     ~HashTable()
     {
         if (table)
             destroyTable(*this, table, capacity());
     }
 
   private:
-    static HashNumber hash1(HashNumber hash0, uint32_t shift) {
-        return hash0 >> shift;
+    HashNumber hash1(HashNumber hash0) const {
+        return hash0 >> hashShift;
     }
 
     struct DoubleHash {
         HashNumber h2;
         HashNumber sizeMask;
     };
 
-    DoubleHash hash2(HashNumber curKeyHash, uint32_t hashShift) const {
+    DoubleHash hash2(HashNumber curKeyHash) const {
         unsigned sizeLog2 = sHashBits - hashShift;
         DoubleHash dh = {
             ((curKeyHash << sizeLog2) >> hashShift) | 1,
             (HashNumber(1) << sizeLog2) - 1
         };
         return dh;
     }
 
@@ -428,33 +428,33 @@ class HashTable : private AllocPolicy
     {
         JS_ASSERT(isLiveHash(keyHash));
         JS_ASSERT(!(keyHash & sCollisionBit));
         JS_ASSERT(collisionBit == 0 || collisionBit == sCollisionBit);
         JS_ASSERT(table);
         METER(stats.searches++);
 
         /* Compute the primary hash address. */
-        HashNumber h1 = hash1(keyHash, hashShift);
+        HashNumber h1 = hash1(keyHash);
         Entry *entry = &table[h1];
 
         /* Miss: return space for a new entry. */
         if (entry->isFree()) {
             METER(stats.misses++);
             return *entry;
         }
 
         /* Hit: return entry. */
         if (entry->matchHash(keyHash) && match(*entry, l)) {
             METER(stats.hits++);
             return *entry;
         }
 
         /* Collision: double hash. */
-        DoubleHash dh = hash2(keyHash, hashShift);
+        DoubleHash dh = hash2(keyHash);
 
         /* Save the first removed entry pointer so we can recycle later. */
         Entry *firstRemoved = NULL;
 
         while(true) {
             if (JS_UNLIKELY(entry->isRemoved())) {
                 if (!firstRemoved)
                     firstRemoved = entry;
@@ -490,27 +490,27 @@ class HashTable : private AllocPolicy
     {
         JS_ASSERT(!(keyHash & sCollisionBit));
         JS_ASSERT(table);
         METER(stats.searches++);
 
         /* N.B. the |keyHash| has already been distributed. */
 
         /* Compute the primary hash address. */
-        HashNumber h1 = hash1(keyHash, hashShift);
+        HashNumber h1 = hash1(keyHash);
         Entry *entry = &table[h1];
 
         /* Miss: return space for a new entry. */
         if (!entry->isLive()) {
             METER(stats.misses++);
             return *entry;
         }
 
         /* Collision: double hash. */
-        DoubleHash dh = hash2(keyHash, hashShift);
+        DoubleHash dh = hash2(keyHash);
 
         while(true) {
             JS_ASSERT(!entry->isRemoved());
             entry->setCollision();
 
             METER(stats.steps++);
             h1 = applyDoubleHash(h1, dh);
 
@@ -627,18 +627,18 @@ class HashTable : private AllocPolicy
             Entry *src = &table[i];
 
             if (!src->isLive() || src->hasCollision()) {
                 ++i;
                 continue;
             }
 
             HashNumber keyHash = src->getKeyHash();
-            HashNumber h1 = hash1(keyHash, hashShift);
-            DoubleHash dh = hash2(keyHash, hashShift);
+            HashNumber h1 = hash1(keyHash);
+            DoubleHash dh = hash2(keyHash);
             Entry *tgt = &table[h1];
             while (true) {
                 if (!tgt->hasCollision()) {
                     Swap(*src, *tgt);
                     tgt->setCollision();
                     break;
                 }