Bug 1290614, part 3 - The last argument to the third XPCNativeSetKey ctor is always the interface count. r=mrbkap
The mPosition field will be eliminated in a later patch.
MozReview-Commit-ID: EyVYZGgUWrH
--- a/js/xpconnect/src/XPCInlines.h
+++ b/js/xpconnect/src/XPCInlines.h
@@ -275,21 +275,20 @@ inline size_t
XPCNativeInterface::OffsetOfMembers()
{
return offsetof(XPCNativeInterface, mMembers);
}
/***************************************************************************/
inline XPCNativeSetKey::XPCNativeSetKey(XPCNativeSet* baseSet,
- XPCNativeInterface* addition,
- uint16_t position)
+ XPCNativeInterface* addition)
: mBaseSet(baseSet)
, mAddition(addition)
- , mPosition(position)
+ , mPosition(baseSet->GetInterfaceCount())
{
MOZ_ASSERT(mBaseSet);
MOZ_ASSERT(mAddition);
MOZ_ASSERT(!mBaseSet->HasInterface(mAddition));
}
/***************************************************************************/
--- a/js/xpconnect/src/XPCWrappedNative.cpp
+++ b/js/xpconnect/src/XPCWrappedNative.cpp
@@ -1013,17 +1013,17 @@ private:
bool
XPCWrappedNative::ExtendSet(XPCNativeInterface* aInterface)
{
AutoJSContext cx;
if (!mSet->HasInterface(aInterface)) {
AutoMarkingNativeSetPtr newSet(cx);
- XPCNativeSetKey key(mSet, aInterface, mSet->GetInterfaceCount());
+ XPCNativeSetKey key(mSet, aInterface);
newSet = XPCNativeSet::GetNewOrUsed(&key);
if (!newSet)
return false;
mSet = newSet;
}
return true;
}
--- a/js/xpconnect/src/XPCWrappedNativeInfo.cpp
+++ b/js/xpconnect/src/XPCWrappedNativeInfo.cpp
@@ -678,18 +678,17 @@ XPCNativeSet::GetNewOrUsed(XPCNativeSet*
// a lot of stuff assumes that sets are created by adding one interface to an
// existing set. So let's just do the slow and easy thing and hope that the
// above optimizations handle the common cases.
XPCNativeSet* currentSet = firstSet;
for (uint32_t i = 0; i < secondSet->mInterfaceCount; ++i) {
XPCNativeInterface* iface = secondSet->mInterfaces[i];
if (!currentSet->HasInterface(iface)) {
// Create a new augmented set, inserting this interface at the end.
- uint32_t pos = currentSet->mInterfaceCount;
- XPCNativeSetKey key(currentSet, iface, pos);
+ XPCNativeSetKey key(currentSet, iface);
currentSet = XPCNativeSet::GetNewOrUsed(&key);
if (!currentSet)
return nullptr;
}
}
// We've got the union set. Hand it back to the caller.
MOZ_ASSERT(currentSet->mInterfaceCount == uniqueCount);
--- a/js/xpconnect/src/xpcprivate.h
+++ b/js/xpconnect/src/xpcprivate.h
@@ -1286,21 +1286,20 @@ public:
// |addition|.
explicit XPCNativeSetKey(XPCNativeInterface* addition)
: mBaseSet(nullptr), mAddition(addition), mPosition(0)
{
MOZ_ASSERT(addition);
}
// This represents the existing set |baseSet| with the interface
- // |addition| inserted at position |position|. |addition| must
+ // |addition| inserted after existing interfaces. |addition| must
// not already be present in |baseSet|.
explicit XPCNativeSetKey(XPCNativeSet* baseSet,
- XPCNativeInterface* addition,
- uint16_t position);
+ XPCNativeInterface* addition);
~XPCNativeSetKey() {}
XPCNativeSet* GetBaseSet() const {return mBaseSet;}
XPCNativeInterface* GetAddition() const {return mAddition;}
uint16_t GetPosition() const {return mPosition;}
PLDHashNumber Hash() const;