Bug 1338168 - micro-optimize GetListenerInfoFor; r=baku,smaug
authorNathan Froyd <froydnj@mozilla.com>
Wed, 15 Feb 2017 11:06:39 -0400
changeset 343123 3cac14211742ccb4b1f98fc4e44236eeb0d7c27e
parent 343122 2f5ea49d65cf21e1ecf7c7c6c348abd3b9d2a456
child 343124 21a0091e7a82839b91bc780aa1156efb5302d7a5
push id37450
push userkwierso@gmail.com
push dateThu, 16 Feb 2017 00:33:57 +0000
treeherderautoland@d8e8cc9d9b68 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbaku, smaug
bugs1338168
milestone54.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1338168 - micro-optimize GetListenerInfoFor; r=baku,smaug We can use nsCOMArray::Forget() to avoid some unnecessary refcounting.
dom/events/EventListenerService.cpp
--- a/dom/events/EventListenerService.cpp
+++ b/dom/events/EventListenerService.cpp
@@ -201,24 +201,17 @@ EventListenerService::GetListenerInfoFor
     elm->GetListenerInfo(&listenerInfos);
   }
 
   int32_t count = listenerInfos.Count();
   if (count == 0) {
     return NS_OK;
   }
 
-  *aOutArray =
-    static_cast<nsIEventListenerInfo**>(
-      moz_xmalloc(sizeof(nsIEventListenerInfo*) * count));
-  NS_ENSURE_TRUE(*aOutArray, NS_ERROR_OUT_OF_MEMORY);
-
-  for (int32_t i = 0; i < count; ++i) {
-    NS_ADDREF((*aOutArray)[i] = listenerInfos[i]);
-  }
+  listenerInfos.Forget(aOutArray);
   *aCount = count;
   return NS_OK;
 }
 
 NS_IMETHODIMP
 EventListenerService::GetEventTargetChainFor(nsIDOMEventTarget* aEventTarget,
                                              bool aComposed,
                                              uint32_t* aCount,