Bug 1290614, part 6 - Hoist out the common loop over all interfaces in XPCNativeSetKey::Hash(). r=mrbkap draft
authorAndrew McCreight <continuation@gmail.com>
Sun, 31 Jul 2016 14:16:52 -0700
changeset 405485 c1ca6e8b171fd3a1c90a016b3cb2e0bbd46108bb
parent 405484 e632153bb8b9e143ad269e1146465b91d4ea5ed9
child 405486 ad4a1565630dedd890011c2b5ecdf5b805ee627e
push id27502
push userbmo:continuation@gmail.com
push dateThu, 25 Aug 2016 14:52:41 +0000
reviewersmrbkap
bugs1290614
milestone51.0a1
Bug 1290614, part 6 - Hoist out the common loop over all interfaces in XPCNativeSetKey::Hash(). r=mrbkap Both cases first hash together all of the existing interfaces. MozReview-Commit-ID: AnUF5uPSPpN
js/xpconnect/src/XPCWrappedNativeInfo.cpp
--- a/js/xpconnect/src/XPCWrappedNativeInfo.cpp
+++ b/js/xpconnect/src/XPCWrappedNativeInfo.cpp
@@ -437,24 +437,22 @@ XPCNativeSetKey::Hash() const
     PLDHashNumber h = 0;
 
     if (!mBaseSet) {
         MOZ_ASSERT(mAddition, "bad key");
         h ^= HashPointer(mAddition);
     } else {
         XPCNativeInterface** current = mBaseSet->GetInterfaceArray();
         uint16_t count = mBaseSet->GetInterfaceCount();
+        for (uint16_t i = 0; i < count; i++) {
+            h ^= HashPointer(*(current++));
+        }
+
         if (mAddition) {
-            for (uint16_t i = 0; i < count; i++) {
-                h ^= HashPointer(*(current++));
-            }
             h ^= HashPointer(mAddition);
-        } else {
-            for (uint16_t i = 0; i < count; i++)
-                h ^= HashPointer(*(current++));
         }
     }
 
     return h;
 }
 
 /***************************************************************************/
 // XPCNativeSet