Bug 805730. Convert HasListenerFor(nsAString) callers to HasListenerFor(nsIAtom*), which is more efficient. r=smaug
authorRobert O'Callahan <robert@ocallahan.org>
Mon, 29 Oct 2012 17:33:51 +1300
changeset 119590 bf45387fc47cbad4cae24d2e2b8723ebb67aff40
parent 119589 f31f3948e433e52aa36a36ab015e766993c03cc5
child 119591 c1b7d0153476c21fb2030b78d1e2af0305ced9fc
push id1997
push userakeybl@mozilla.com
push dateMon, 07 Jan 2013 21:25:26 +0000
treeherdermozilla-beta@4baf45cdcf21 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs805730
milestone19.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 805730. Convert HasListenerFor(nsAString) callers to HasListenerFor(nsIAtom*), which is more efficient. r=smaug
accessible/src/base/nsCoreUtils.cpp
content/base/src/WebSocket.cpp
content/base/src/nsXMLHttpRequest.cpp
content/events/src/nsDOMEventTargetHelper.h
dom/devicestorage/nsDeviceStorage.cpp
--- a/accessible/src/base/nsCoreUtils.cpp
+++ b/accessible/src/base/nsCoreUtils.cpp
@@ -26,16 +26,17 @@
 #include "nsIScrollableFrame.h"
 #include "nsEventStateManager.h"
 #include "nsISelectionPrivate.h"
 #include "nsISelectionController.h"
 #include "nsPIDOMWindow.h"
 #include "nsGUIEvent.h"
 #include "nsIView.h"
 #include "nsLayoutUtils.h"
+#include "nsGkAtoms.h"
 
 #include "nsComponentManagerUtils.h"
 #include "nsIInterfaceRequestorUtils.h"
 #include "mozilla/dom/Element.h"
 
 #include "nsITreeBoxObject.h"
 #include "nsIDocShellTreeItem.h"
 #include "nsITreeColumns.h"
@@ -47,19 +48,19 @@
 bool
 nsCoreUtils::HasClickListener(nsIContent *aContent)
 {
   NS_ENSURE_TRUE(aContent, false);
   nsEventListenerManager* listenerManager =
     aContent->GetListenerManager(false);
 
   return listenerManager &&
-    (listenerManager->HasListenersFor(NS_LITERAL_STRING("click")) ||
-     listenerManager->HasListenersFor(NS_LITERAL_STRING("mousedown")) ||
-     listenerManager->HasListenersFor(NS_LITERAL_STRING("mouseup")));
+    (listenerManager->HasListenersFor(nsGkAtoms::onclick) ||
+     listenerManager->HasListenersFor(nsGkAtoms::onmousedown) ||
+     listenerManager->HasListenersFor(nsGkAtoms::onmouseup));
 }
 
 void
 nsCoreUtils::DispatchClickEvent(nsITreeBoxObject *aTreeBoxObj,
                                 int32_t aRowIndex, nsITreeColumn *aColumn,
                                 const nsCString& aPseudoElt)
 {
   nsCOMPtr<nsIDOMElement> tcElm;
--- a/content/base/src/WebSocket.cpp
+++ b/content/base/src/WebSocket.cpp
@@ -1076,31 +1076,31 @@ WebSocket::UpdateMustKeepAlive()
 
   bool shouldKeepAlive = false;
 
   if (mListenerManager) {
     switch (mReadyState)
     {
       case WebSocket::CONNECTING:
       {
-        if (mListenerManager->HasListenersFor(NS_LITERAL_STRING("open")) ||
-            mListenerManager->HasListenersFor(NS_LITERAL_STRING("message")) ||
-            mListenerManager->HasListenersFor(NS_LITERAL_STRING("error")) ||
-            mListenerManager->HasListenersFor(NS_LITERAL_STRING("close"))) {
+        if (mListenerManager->HasListenersFor(nsGkAtoms::onopen) ||
+            mListenerManager->HasListenersFor(nsGkAtoms::onmessage) ||
+            mListenerManager->HasListenersFor(nsGkAtoms::onerror) ||
+            mListenerManager->HasListenersFor(nsGkAtoms::onclose)) {
           shouldKeepAlive = true;
         }
       }
       break;
 
       case WebSocket::OPEN:
       case WebSocket::CLOSING:
       {
-        if (mListenerManager->HasListenersFor(NS_LITERAL_STRING("message")) ||
-            mListenerManager->HasListenersFor(NS_LITERAL_STRING("error")) ||
-            mListenerManager->HasListenersFor(NS_LITERAL_STRING("close")) ||
+        if (mListenerManager->HasListenersFor(nsGkAtoms::onmessage) ||
+            mListenerManager->HasListenersFor(nsGkAtoms::onerror) ||
+            mListenerManager->HasListenersFor(nsGkAtoms::onclose) ||
             mOutgoingBufferedAmount != 0) {
           shouldKeepAlive = true;
         }
       }
       break;
 
       case WebSocket::CLOSED:
       {
--- a/content/base/src/nsXMLHttpRequest.cpp
+++ b/content/base/src/nsXMLHttpRequest.cpp
@@ -2258,17 +2258,17 @@ nsXMLHttpRequest::OnStartRequest(nsIRequ
     rv = mXMLParserStreamListener->OnStartRequest(request, ctxt);
     NS_ENSURE_SUCCESS(rv, rv);
   }
 
   // We won't get any progress events anyway if we didn't have progress
   // events when starting the request - so maybe no need to start timer here.
   if (NS_SUCCEEDED(rv) &&
       (mState & XML_HTTP_REQUEST_ASYNC) &&
-      HasListenersFor(NS_LITERAL_STRING(PROGRESS_STR))) {
+      HasListenersFor(nsGkAtoms::onprogress)) {
     StartProgressEventTimer();
   }
 
   return NS_OK;
 }
 
 /* void onStopRequest (in nsIRequest request, in nsISupports ctxt, in nsresult status, in wstring statusArg); */
 NS_IMETHODIMP
@@ -2782,18 +2782,18 @@ nsXMLHttpRequest::Send(nsIVariant* aVari
     return NS_ERROR_NOT_INITIALIZED;
   }
 
 
   // nsIRequest::LOAD_BACKGROUND prevents throbber from becoming active, which
   // in turn keeps STOP button from becoming active.  If the consumer passed in
   // a progress event handler we must load with nsIRequest::LOAD_NORMAL or
   // necko won't generate any progress notifications.
-  if (HasListenersFor(NS_LITERAL_STRING(PROGRESS_STR)) ||
-      (mUpload && mUpload->HasListenersFor(NS_LITERAL_STRING(PROGRESS_STR)))) {
+  if (HasListenersFor(nsGkAtoms::onprogress) ||
+      (mUpload && mUpload->HasListenersFor(nsGkAtoms::onprogress))) {
     nsLoadFlags loadFlags;
     mChannel->GetLoadFlags(&loadFlags);
     loadFlags &= ~nsIRequest::LOAD_BACKGROUND;
     loadFlags |= nsIRequest::LOAD_NORMAL;
     mChannel->SetLoadFlags(loadFlags);
   }
 
   // XXX We should probably send a warning to the JS console
@@ -3149,17 +3149,17 @@ nsXMLHttpRequest::Send(nsIVariant* aVari
       NS_DispatchToCurrentThread(resumeTimeoutRunnable);
     }
   } else {
     // Now that we've successfully opened the channel, we can change state.  Note
     // that this needs to come after the AsyncOpen() and rv check, because this
     // can run script that would try to restart this request, and that could end
     // up doing our AsyncOpen on a null channel if the reentered AsyncOpen fails.
     ChangeState(XML_HTTP_REQUEST_SENT);
-    if (mUpload && mUpload->HasListenersFor(NS_LITERAL_STRING(PROGRESS_STR))) {
+    if (mUpload && mUpload->HasListenersFor(nsGkAtoms::onprogress)) {
       StartProgressEventTimer();
     }
     DispatchProgressEvent(this, NS_LITERAL_STRING(LOADSTART_STR), false,
                           0, 0);
     if (mUpload && !mUploadComplete) {
       DispatchProgressEvent(mUpload, NS_LITERAL_STRING(LOADSTART_STR), true,
                             0, mUploadTotal);
     }
--- a/content/events/src/nsDOMEventTargetHelper.h
+++ b/content/events/src/nsDOMEventTargetHelper.h
@@ -79,19 +79,19 @@ public:
     }
 #endif
 
     return static_cast<nsDOMEventTargetHelper*>(target);
   }
 
   void Init(JSContext* aCx = nullptr);
 
-  bool HasListenersFor(const nsAString& aType)
+  bool HasListenersFor(nsIAtom* aTypeWithOn)
   {
-    return mListenerManager && mListenerManager->HasListenersFor(aType);
+    return mListenerManager && mListenerManager->HasListenersFor(aTypeWithOn);
   }
 
   nsresult SetEventHandler(nsIAtom* aType,
                            JSContext* aCx,
                            const JS::Value& aValue);
   void GetEventHandler(nsIAtom* aType,
                        JSContext* aCx,
                        JS::Value* aValue);
--- a/dom/devicestorage/nsDeviceStorage.cpp
+++ b/dom/devicestorage/nsDeviceStorage.cpp
@@ -2253,17 +2253,17 @@ nsDOMDeviceStorage::AddSystemEventListen
 
 NS_IMETHODIMP
 nsDOMDeviceStorage::RemoveEventListener(const nsAString & aType,
                                         nsIDOMEventListener *aListener,
                                         bool aUseCapture)
 {
   nsDOMEventTargetHelper::RemoveEventListener(aType, aListener, false);
 
-  if (mIsWatchingFile && !HasListenersFor(NS_LITERAL_STRING("change"))) {
+  if (mIsWatchingFile && !HasListenersFor(nsGkAtoms::onchange)) {
     mIsWatchingFile = false;
     nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
     obs->RemoveObserver(this, "file-watcher-update");
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP