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
--- 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