Bug 1290614, part 7 - Further refactor XPCNativeSetKey::Hash. r=mrbkap draft
authorAndrew McCreight <continuation@gmail.com>
Sun, 31 Jul 2016 14:19:31 -0700
changeset 405486 ad4a1565630dedd890011c2b5ecdf5b805ee627e
parent 405485 c1ca6e8b171fd3a1c90a016b3cb2e0bbd46108bb
child 529453 87603fba5744018bb4d2413d266702c02cda9c59
push id27502
push userbmo:continuation@gmail.com
push dateThu, 25 Aug 2016 14:52:41 +0000
reviewersmrbkap
bugs1290614, 1290239
milestone51.0a1
Bug 1290614, part 7 - Further refactor XPCNativeSetKey::Hash. r=mrbkap Now we can see what is really happening in Hash: first hash the interfaces from the base set, if any, then hash the additional interface, if any. Note that this function is wrong when mBaseSet is null. This will be fixed in bug 1290239. MozReview-Commit-ID: KaxQ57ofO1D
js/xpconnect/src/XPCWrappedNativeInfo.cpp
--- a/js/xpconnect/src/XPCWrappedNativeInfo.cpp
+++ b/js/xpconnect/src/XPCWrappedNativeInfo.cpp
@@ -431,29 +431,26 @@ HashPointer(const void* ptr)
     return NS_PTR_TO_UINT32(ptr) >> 2;
 }
 
 PLDHashNumber
 XPCNativeSetKey::Hash() const
 {
     PLDHashNumber h = 0;
 
-    if (!mBaseSet) {
-        MOZ_ASSERT(mAddition, "bad key");
-        h ^= HashPointer(mAddition);
-    } else {
+    if (mBaseSet) {
         XPCNativeInterface** current = mBaseSet->GetInterfaceArray();
         uint16_t count = mBaseSet->GetInterfaceCount();
         for (uint16_t i = 0; i < count; i++) {
             h ^= HashPointer(*(current++));
         }
+    }
 
-        if (mAddition) {
-            h ^= HashPointer(mAddition);
-        }
+    if (mAddition) {
+        h ^= HashPointer(mAddition);
     }
 
     return h;
 }
 
 /***************************************************************************/
 // XPCNativeSet