Bug 1390692 - Remove the unnecessary second QI entry for nsCycleCollectionISupports. r=peterv draft
authorAndrew McCreight <continuation@gmail.com>
Tue, 22 Aug 2017 12:51:10 -0700
changeset 650736 6b16d7d880ef3123a7bebcb9df01b661d5164718
parent 650685 ab30809b4c8e53b8723c062340960680ca419c7f
child 727478 2684ecf4c1aa55ab3ca73144ef3a9a5b98f4cb82
push id75477
push userbmo:continuation@gmail.com
push dateTue, 22 Aug 2017 20:01:46 +0000
reviewerspeterv
bugs1390692
milestone57.0a1
Bug 1390692 - Remove the unnecessary second QI entry for nsCycleCollectionISupports. r=peterv MozReview-Commit-ID: 4o2QZhdomg2
xpcom/base/nsAgg.h
xpcom/base/nsCycleCollectionParticipant.h
--- a/xpcom/base/nsAgg.h
+++ b/xpcom/base/nsAgg.h
@@ -247,19 +247,34 @@ public:
 NS_DEFINE_STATIC_IID_ACCESSOR(nsAggregatedCycleCollectionParticipant,
                               NS_AGGREGATED_CYCLECOLLECTIONPARTICIPANT_IID)
 
 // for use with QI macros in nsISupportsUtils.h:
 
 #define NS_INTERFACE_MAP_BEGIN_AGGREGATED(_class)                           \
   NS_IMPL_AGGREGATED_QUERY_HEAD(_class)
 
+#define NS_IMPL_QUERY_CYCLE_COLLECTION(_class)                              \
+  if ( aIID.Equals(NS_GET_IID(nsXPCOMCycleCollectionParticipant)) ) {       \
+    *aInstancePtr = NS_CYCLE_COLLECTION_PARTICIPANT(_class);                \
+    return NS_OK;                                                           \
+  } else
+
 #define NS_INTERFACE_MAP_ENTRY_CYCLE_COLLECTION_AGGREGATED(_class)          \
   NS_IMPL_QUERY_CYCLE_COLLECTION(_class)
 
+#define NS_IMPL_QUERY_CYCLE_COLLECTION_ISUPPORTS(_class)                    \
+  if ( aIID.Equals(NS_GET_IID(nsCycleCollectionISupports)) ) {              \
+    *aInstancePtr = NS_CYCLE_COLLECTION_CLASSNAME(_class)::Upcast(this);    \
+    return NS_OK;                                                           \
+  } else
+
+#define NS_INTERFACE_MAP_ENTRY_CYCLE_COLLECTION_ISUPPORTS(_class)           \
+  NS_IMPL_QUERY_CYCLE_COLLECTION_ISUPPORTS(_class)
+
 #define NS_INTERFACE_MAP_ENTRIES_CYCLE_COLLECTION_AGGREGATED(_class)        \
   NS_INTERFACE_MAP_ENTRY_CYCLE_COLLECTION_AGGREGATED(_class)                \
   NS_INTERFACE_MAP_ENTRY_CYCLE_COLLECTION_ISUPPORTS(_class)
 
 #define NS_IMPL_AGGREGATED_QUERY_HEAD(_class)                               \
 nsresult                                                                    \
 _class::AggregatedQueryInterface(REFNSIID aIID, void** aInstancePtr)        \
 {                                                                           \
--- a/xpcom/base/nsCycleCollectionParticipant.h
+++ b/xpcom/base/nsCycleCollectionParticipant.h
@@ -281,34 +281,22 @@ NS_DEFINE_STATIC_IID_ACCESSOR(nsXPCOMCyc
 
 ///////////////////////////////////////////////////////////////////////////////
 // Helpers for implementing a QI to nsXPCOMCycleCollectionParticipant
 ///////////////////////////////////////////////////////////////////////////////
 
 #define NS_CYCLE_COLLECTION_CLASSNAME(_class)                                  \
         _class::NS_CYCLE_COLLECTION_INNERCLASS
 
-#define NS_IMPL_QUERY_CYCLE_COLLECTION(_class)                                 \
-  if ( aIID.Equals(NS_GET_IID(nsXPCOMCycleCollectionParticipant)) ) {          \
-    *aInstancePtr = NS_CYCLE_COLLECTION_PARTICIPANT(_class);                   \
-    return NS_OK;                                                              \
-  } else
-
-#define NS_IMPL_QUERY_CYCLE_COLLECTION_ISUPPORTS(_class)                       \
-  if ( aIID.Equals(NS_GET_IID(nsCycleCollectionISupports)) ) {                 \
-    *aInstancePtr = NS_CYCLE_COLLECTION_CLASSNAME(_class)::Upcast(this);       \
-    return NS_OK;                                                              \
-  } else
-
 // The IIDs for nsXPCOMCycleCollectionParticipant and nsCycleCollectionISupports
 // are special in that they only differ in their last byte.  This allows for the
 // optimization below where we first check the first three words of the IID and
 // if we find a match we check the last word to decide which case we have to
 // deal with.
-#define NS_INTERFACE_MAP_ENTRY_CYCLE_COLLECTION(_class)                        \
+#define NS_INTERFACE_MAP_ENTRIES_CYCLE_COLLECTION(_class)                      \
   if (TopThreeWordsEquals(aIID, NS_GET_IID(nsXPCOMCycleCollectionParticipant), \
                           NS_GET_IID(nsCycleCollectionISupports)) &&           \
        /* The calls to LowWordEquals here are repeated inside the if branch.   \
           This is due to the fact that we need to maintain the if/else chain   \
           for these macros, so that the control flow never enters the if branch\
           unless if we're certain one of the LowWordEquals() branches will get \
           executed. */                                                         \
       (LowWordEquals(aIID, NS_GET_IID(nsXPCOMCycleCollectionParticipant)) ||   \
@@ -321,31 +309,22 @@ NS_DEFINE_STATIC_IID_ACCESSOR(nsXPCOMCyc
       *aInstancePtr = NS_CYCLE_COLLECTION_CLASSNAME(_class)::Upcast(this);     \
       return NS_OK;                                                            \
     } else {                                                                   \
       /* Avoid warnings about foundInterface being left uninitialized. */      \
       foundInterface = nullptr;                                                \
     }                                                                          \
   } else
 
-#define NS_INTERFACE_MAP_ENTRY_CYCLE_COLLECTION_ISUPPORTS(_class)              \
-  NS_IMPL_QUERY_CYCLE_COLLECTION_ISUPPORTS(_class)
-
-#define NS_INTERFACE_MAP_ENTRIES_CYCLE_COLLECTION(_class)                      \
-  NS_INTERFACE_MAP_ENTRY_CYCLE_COLLECTION(_class)                              \
-  NS_INTERFACE_MAP_ENTRY_CYCLE_COLLECTION_ISUPPORTS(_class)
-
 #define NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(_class)                        \
   NS_INTERFACE_MAP_BEGIN(_class)                                               \
     NS_INTERFACE_MAP_ENTRIES_CYCLE_COLLECTION(_class)
 
 #define NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(_class)              \
-  NS_INTERFACE_MAP_BEGIN(_class)                                               \
-    NS_INTERFACE_MAP_ENTRY_CYCLE_COLLECTION(_class)                            \
-    NS_INTERFACE_MAP_ENTRY_CYCLE_COLLECTION_ISUPPORTS(_class)
+  NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(_class)
 
 #define NS_INTERFACE_TABLE_TO_MAP_SEGUE_CYCLE_COLLECTION(_class)  \
   if (rv == NS_OK) return rv; \
   nsISupports* foundInterface; \
   NS_INTERFACE_MAP_ENTRIES_CYCLE_COLLECTION(_class)
 
 // The IIDs for nsXPCOMCycleCollectionParticipant and nsCycleCollectionISupports
 // are special in that they only differ in their last byte.  This allows for the