Bug 958643, part 4 - Inline CreateHolderIfNeeded. r=krizsa draft
authorAndrew McCreight <continuation@gmail.com>
Wed, 20 Sep 2017 10:21:59 -0700
changeset 667832 4980b300ccd4d1eedadc58f900c71a7ebe31dc32
parent 667831 704d11432d775016b29aefb40e97d328585971ea
child 667833 f8bc5fd9c18e272abf6ad93409768721b898dbc5
push id80866
push userbmo:continuation@gmail.com
push dateWed, 20 Sep 2017 20:39:49 +0000
reviewerskrizsa
bugs958643
milestone57.0a1
Bug 958643, part 4 - Inline CreateHolderIfNeeded. r=krizsa The last argument is always null, so we don't need this function any more. MozReview-Commit-ID: 5YWMO9ywZK3
js/xpconnect/src/XPCConvert.cpp
--- a/js/xpconnect/src/XPCConvert.cpp
+++ b/js/xpconnect/src/XPCConvert.cpp
@@ -709,32 +709,16 @@ XPCConvert::JSData2Native(void* d, Handl
     }
     default:
         NS_ERROR("bad type");
         return false;
     }
     return true;
 }
 
-static inline bool
-CreateHolderIfNeeded(JSContext* cx, HandleObject obj, MutableHandleValue d,
-                     nsIXPConnectJSObjectHolder** dest)
-{
-    if (dest) {
-        if (!obj)
-            return false;
-        RefPtr<XPCJSObjectHolder> objHolder = new XPCJSObjectHolder(cx, obj);
-        objHolder.forget(dest);
-    }
-
-    d.setObjectOrNull(obj);
-
-    return true;
-}
-
 /***************************************************************************/
 // static
 bool
 XPCConvert::NativeInterface2JSObject(MutableHandleValue d,
                                      xpcObjectHelper& aHelper,
                                      const nsID* iid,
                                      bool allowNativeWrapper,
                                      nsresult* pErr)
@@ -774,29 +758,31 @@ XPCConvert::NativeInterface2JSObject(Mut
         js::AssertSameCompartment(cx, global);
         flat = cache->WrapObject(cx, nullptr);
         if (!flat)
             return false;
     }
     if (flat) {
         if (allowNativeWrapper && !JS_WrapObject(cx, &flat))
             return false;
-        return CreateHolderIfNeeded(cx, flat, d, nullptr);
+        d.setObjectOrNull(flat);
+        return true;
     }
 
     if (iid->Equals(NS_GET_IID(nsISupports))) {
         // Check for a Promise being returned via nsISupports.  In that
         // situation, we want to dig out its underlying JS object and return
         // that.
         RefPtr<Promise> promise = do_QueryObject(aHelper.Object());
         if (promise) {
             flat = promise->PromiseObj();
             if (!JS_WrapObject(cx, &flat))
                 return false;
-            return CreateHolderIfNeeded(cx, flat, d, nullptr);
+            d.setObjectOrNull(flat);
+            return true;
         }
     }
 
     // Don't double wrap CPOWs. This is a temporary measure for compatibility
     // with objects that don't provide necessary QIs (such as objects under
     // the new DOM bindings). We expect the other side of the CPOW to have
     // the appropriate wrappers in place.
     RootedObject cpow(cx, UnwrapNativeCPOW(aHelper.Object()));