Bug 1290614, part 3 - The last argument to the third XPCNativeSetKey ctor is always the interface count. r=mrbkap draft
authorAndrew McCreight <continuation@gmail.com>
Sun, 31 Jul 2016 13:36:39 -0700
changeset 405482 98baf421124a650adffce94e6278924c672a57fc
parent 405481 b8acdca031f427b61e4344fd9f5affc934cb54c3
child 405483 1b6fd894da82cb1e47d82c77719ad9bb070b386c
push id27502
push userbmo:continuation@gmail.com
push dateThu, 25 Aug 2016 14:52:41 +0000
reviewersmrbkap
bugs1290614
milestone51.0a1
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
js/xpconnect/src/XPCInlines.h
js/xpconnect/src/XPCWrappedNative.cpp
js/xpconnect/src/XPCWrappedNativeInfo.cpp
js/xpconnect/src/xpcprivate.h
--- 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;