Bug 1262400 - remove outer pointers from nsCreateInstance* classes; r=erahm
authorNathan Froyd <froydnj.com>
Thu, 14 Apr 2016 11:30:59 -0400
changeset 351760 62f56187fc278162b71ece33c8457f305f9fe5b7
parent 351759 a29c9be8af13c01e80c8bf936289fc167d4ce90c
child 351761 17bc12e98c25c8bf9fe5ce9fcccd180be5c83ee4
push id15527
push userbmo:rail@mozilla.com
push dateFri, 15 Apr 2016 01:44:41 +0000
reviewerserahm
bugs1262400
milestone48.0a1
Bug 1262400 - remove outer pointers from nsCreateInstance* classes; r=erahm Outer pointers for object aggregation never get used. Having these always-null pointers around means extra space to store them and extra instructions to deal with them. Let's just remove them.
xpcom/glue/nsComponentManagerUtils.cpp
xpcom/glue/nsComponentManagerUtils.h
--- a/xpcom/glue/nsComponentManagerUtils.cpp
+++ b/xpcom/glue/nsComponentManagerUtils.cpp
@@ -175,45 +175,45 @@ CallGetClassObject(const char* aContract
                                                                 aIID, aResult);
 }
 
 #endif
 
 nsresult
 nsCreateInstanceByCID::operator()(const nsIID& aIID, void** aInstancePtr) const
 {
-  nsresult status = CallCreateInstance(mCID, mOuter, aIID, aInstancePtr);
+  nsresult status = CallCreateInstance(mCID, nullptr, aIID, aInstancePtr);
   if (NS_FAILED(status)) {
     *aInstancePtr = 0;
   }
   if (mErrorPtr) {
     *mErrorPtr = status;
   }
   return status;
 }
 
 nsresult
 nsCreateInstanceByContractID::operator()(const nsIID& aIID,
                                          void** aInstancePtr) const
 {
-  nsresult status = CallCreateInstance(mContractID, mOuter, aIID, aInstancePtr);
+  nsresult status = CallCreateInstance(mContractID, nullptr, aIID, aInstancePtr);
   if (NS_FAILED(status)) {
     *aInstancePtr = 0;
   }
   if (mErrorPtr) {
     *mErrorPtr = status;
   }
   return status;
 }
 
 nsresult
 nsCreateInstanceFromFactory::operator()(const nsIID& aIID,
                                         void** aInstancePtr) const
 {
-  nsresult status = mFactory->CreateInstance(mOuter, aIID, aInstancePtr);
+  nsresult status = mFactory->CreateInstance(nullptr, aIID, aInstancePtr);
   if (NS_FAILED(status)) {
     *aInstancePtr = 0;
   }
   if (mErrorPtr) {
     *mErrorPtr = status;
   }
   return status;
 }
--- a/xpcom/glue/nsComponentManagerUtils.h
+++ b/xpcom/glue/nsComponentManagerUtils.h
@@ -24,108 +24,79 @@ nsresult CallGetClassObject(const nsCID&
 
 nsresult CallGetClassObject(const char* aContractID, const nsIID& aIID,
                             void** aResult);
 
 
 class MOZ_STACK_CLASS nsCreateInstanceByCID final : public nsCOMPtr_helper
 {
 public:
-  nsCreateInstanceByCID(const nsCID& aCID, nsISupports* aOuter,
-                        nsresult* aErrorPtr)
+  nsCreateInstanceByCID(const nsCID& aCID, nsresult* aErrorPtr)
     : mCID(aCID)
-    , mOuter(aOuter)
     , mErrorPtr(aErrorPtr)
   {
   }
 
   virtual nsresult NS_FASTCALL operator()(const nsIID&, void**) const
     override;
 
 private:
   const nsCID&    mCID;
-  nsISupports* MOZ_NON_OWNING_REF mOuter;
   nsresult*       mErrorPtr;
 };
 
 class MOZ_STACK_CLASS nsCreateInstanceByContractID final : public nsCOMPtr_helper
 {
 public:
-  nsCreateInstanceByContractID(const char* aContractID, nsISupports* aOuter,
-                               nsresult* aErrorPtr)
+  nsCreateInstanceByContractID(const char* aContractID, nsresult* aErrorPtr)
     : mContractID(aContractID)
-    , mOuter(aOuter)
     , mErrorPtr(aErrorPtr)
   {
   }
 
   virtual nsresult NS_FASTCALL operator()(const nsIID&, void**) const override;
 
 private:
   const char*   mContractID;
-  nsISupports* MOZ_NON_OWNING_REF mOuter;
   nsresult*     mErrorPtr;
 };
 
 class MOZ_STACK_CLASS nsCreateInstanceFromFactory final : public nsCOMPtr_helper
 {
 public:
-  nsCreateInstanceFromFactory(nsIFactory* aFactory, nsISupports* aOuter,
-                              nsresult* aErrorPtr)
+  nsCreateInstanceFromFactory(nsIFactory* aFactory, nsresult* aErrorPtr)
     : mFactory(aFactory)
-    , mOuter(aOuter)
     , mErrorPtr(aErrorPtr)
   {
   }
 
   virtual nsresult NS_FASTCALL operator()(const nsIID&, void**) const override;
 
 private:
   nsIFactory* MOZ_NON_OWNING_REF mFactory;
-  nsISupports* MOZ_NON_OWNING_REF mOuter;
   nsresult*     mErrorPtr;
 };
 
 
 inline const nsCreateInstanceByCID
 do_CreateInstance(const nsCID& aCID, nsresult* aError = 0)
 {
-  return nsCreateInstanceByCID(aCID, 0, aError);
-}
-
-inline const nsCreateInstanceByCID
-do_CreateInstance(const nsCID& aCID, nsISupports* aOuter, nsresult* aError = 0)
-{
-  return nsCreateInstanceByCID(aCID, aOuter, aError);
+  return nsCreateInstanceByCID(aCID, aError);
 }
 
 inline const nsCreateInstanceByContractID
 do_CreateInstance(const char* aContractID, nsresult* aError = 0)
 {
-  return nsCreateInstanceByContractID(aContractID, 0, aError);
-}
-
-inline const nsCreateInstanceByContractID
-do_CreateInstance(const char* aContractID, nsISupports* aOuter,
-                  nsresult* aError = 0)
-{
-  return nsCreateInstanceByContractID(aContractID, aOuter, aError);
+  return nsCreateInstanceByContractID(aContractID, aError);
 }
 
 inline const nsCreateInstanceFromFactory
 do_CreateInstance(nsIFactory* aFactory, nsresult* aError = 0)
 {
-  return nsCreateInstanceFromFactory(aFactory, 0, aError);
-}
-
-inline const nsCreateInstanceFromFactory
-do_CreateInstance(nsIFactory* aFactory, nsISupports* aOuter,
-                  nsresult* aError = 0)
-{
-  return nsCreateInstanceFromFactory(aFactory, aOuter, aError);
+  return nsCreateInstanceFromFactory(aFactory, aError);
 }
 
 
 class MOZ_STACK_CLASS nsGetClassObjectByCID final : public nsCOMPtr_helper
 {
 public:
   nsGetClassObjectByCID(const nsCID& aCID, nsresult* aErrorPtr)
     : mCID(aCID)