Bug 1190436 - Part 2: Use an early return in XPCConvert::JSObject2NativeInterface. r=gabor
authorAndrew McCreight <continuation@gmail.com>
Mon, 03 Aug 2015 11:48:00 -0400
changeset 289480 9e2da56502735465817b33a3b7fc76f48a5afadf
parent 289479 318d42434ec3a937c4bd89253edfa76e9986d8e6
child 289481 0aa81b06bc0202293af921187ef6cd240474b8d6
push id934
push userraliiev@mozilla.com
push dateMon, 26 Oct 2015 12:58:05 +0000
treeherdermozilla-release@05704e35c1d0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgabor
bugs1190436
milestone42.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 1190436 - Part 2: Use an early return in XPCConvert::JSObject2NativeInterface. r=gabor
js/xpconnect/src/XPCConvert.cpp
--- a/js/xpconnect/src/XPCConvert.cpp
+++ b/js/xpconnect/src/XPCConvert.cpp
@@ -918,49 +918,43 @@ XPCConvert::JSObject2NativeInterface(voi
         if (wrappedNative) {
             iface = wrappedNative->GetIdentityObject();
             return NS_SUCCEEDED(iface->QueryInterface(*iid, dest));
         }
         // else...
 
         // Deal with slim wrappers here.
         if (GetISupportsFromJSObject(inner ? inner : src, &iface)) {
-            if (iface)
-                return NS_SUCCEEDED(iface->QueryInterface(*iid, dest));
-
-            return false;
+            return iface && NS_SUCCEEDED(iface->QueryInterface(*iid, dest));
         }
     }
 
-    // else...
-
     nsRefPtr<nsXPCWrappedJS> wrapper;
     nsresult rv = nsXPCWrappedJS::GetNewOrUsed(src, *iid, getter_AddRefs(wrapper));
     if (pErr)
         *pErr = rv;
-    if (NS_SUCCEEDED(rv) && wrapper) {
-        // If the caller wanted to aggregate this JS object to a native,
-        // attach it to the wrapper. Note that we allow a maximum of one
-        // aggregated native for a given XPCWrappedJS.
-        if (aOuter)
-            wrapper->SetAggregatedNativeObject(aOuter);
+
+    if (NS_FAILED(rv) || !wrapper)
+        return false;
+
+    // If the caller wanted to aggregate this JS object to a native,
+    // attach it to the wrapper. Note that we allow a maximum of one
+    // aggregated native for a given XPCWrappedJS.
+    if (aOuter)
+        wrapper->SetAggregatedNativeObject(aOuter);
 
-        // We need to go through the QueryInterface logic to make this return
-        // the right thing for the various 'special' interfaces; e.g.
-        // nsIPropertyBag. We must use AggregatedQueryInterface in cases where
-        // there is an outer to avoid nasty recursion.
-        rv = aOuter ? wrapper->AggregatedQueryInterface(*iid, dest) :
-                      wrapper->QueryInterface(*iid, dest);
-        if (pErr)
-            *pErr = rv;
-        return NS_SUCCEEDED(rv);
-    }
-
-    // else...
-    return false;
+    // We need to go through the QueryInterface logic to make this return
+    // the right thing for the various 'special' interfaces; e.g.
+    // nsIPropertyBag. We must use AggregatedQueryInterface in cases where
+    // there is an outer to avoid nasty recursion.
+    rv = aOuter ? wrapper->AggregatedQueryInterface(*iid, dest) :
+        wrapper->QueryInterface(*iid, dest);
+    if (pErr)
+        *pErr = rv;
+    return NS_SUCCEEDED(rv);
 }
 
 /***************************************************************************/
 /***************************************************************************/
 
 // static
 nsresult
 XPCConvert::ConstructException(nsresult rv, const char* message,