Bug 1348464 - Avoid two virtual calls in NS_URIChainHasFlags(); r=mcmanus
authorEhsan Akhgari <ehsan@mozilla.com>
Fri, 17 Mar 2017 22:03:16 -0400
changeset 348362 a034f667da3bacd385326e7d86c76bd57e1234be
parent 348361 6436030e3e6348fdaaf15dcf33f67c53ce73716a
child 348363 ed933de5aa163ee108fa894b6367cebbe1bbd0a6
push id39126
push userarchaeopteryx@coole-files.de
push dateSun, 19 Mar 2017 15:37:50 +0000
treeherderautoland@53392221fe78 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmcmanus
bugs1348464
milestone55.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 1348464 - Avoid two virtual calls in NS_URIChainHasFlags(); r=mcmanus
netwerk/base/nsNetUtil.cpp
--- a/netwerk/base/nsNetUtil.cpp
+++ b/netwerk/base/nsNetUtil.cpp
@@ -63,16 +63,17 @@
 #include "plstr.h"
 #include "nsINestedURI.h"
 #include "mozilla/dom/nsCSPUtils.h"
 #include "mozilla/net/HttpBaseChannel.h"
 #include "nsIScriptError.h"
 #include "nsISiteSecurityService.h"
 #include "nsHttpHandler.h"
 #include "nsNSSComponent.h"
+#include "nsIOService.h"
 
 #ifdef MOZ_WIDGET_GONK
 #include "nsINetworkManager.h"
 #include "nsThreadUtils.h" // for NS_IsMainThread
 #endif
 
 #include <limits>
 
@@ -1851,21 +1852,22 @@ NS_GetFinalChannelURI(nsIChannel *channe
     return channel->GetOriginalURI(uri);
 }
 
 nsresult
 NS_URIChainHasFlags(nsIURI   *uri,
                     uint32_t  flags,
                     bool     *result)
 {
-    nsresult rv;
-    nsCOMPtr<nsINetUtil> util = do_GetNetUtil(&rv);
-    NS_ENSURE_SUCCESS(rv, rv);
+    // Avoid AddRef and Release'ing the IO service as this can show up in
+    // profiles...
+    auto ios = nsIOService::GetInstance();
+    NS_ENSURE_TRUE(ios, NS_ERROR_FAILURE);
 
-    return util->URIChainHasFlags(uri, flags, result);
+    return ios->URIChainHasFlags(uri, flags, result);
 }
 
 uint32_t
 NS_SecurityHashURI(nsIURI *aURI)
 {
     nsCOMPtr<nsIURI> baseURI = NS_GetInnermostURI(aURI);
 
     nsAutoCString scheme;