Bug 1259877 - Intl.cpp:GetInternals should directly return its result, not go via outparam. r=till
authorJeff Walden <jwalden@mit.edu>
Fri, 18 Mar 2016 17:41:01 -0700
changeset 290945 de7e03fdff65b86744f8ce59b036ea86caf6df8d
parent 290944 0ff7a5a4b24f76859762f1e93ad9c617b8f3c643
child 290946 61f736c678a3e18794c219e71f10b785ed3225ce
push id19656
push usergwagner@mozilla.com
push dateMon, 04 Apr 2016 13:43:23 +0000
treeherderb2g-inbound@e99061fde28a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstill
bugs1259877
milestone48.0a1
Bug 1259877 - Intl.cpp:GetInternals should directly return its result, not go via outparam. r=till
js/src/builtin/Intl.cpp
--- a/js/src/builtin/Intl.cpp
+++ b/js/src/builtin/Intl.cpp
@@ -535,40 +535,40 @@ intl_availableLocales(JSContext* cx, Cou
 #endif
     result.setObject(*locales);
     return true;
 }
 
 /**
  * Returns the object holding the internal properties for obj.
  */
-static bool
-GetInternals(JSContext* cx, HandleObject obj, MutableHandleObject internals)
+static JSObject*
+GetInternals(JSContext* cx, HandleObject obj)
 {
     RootedValue getInternalsValue(cx);
     if (!GlobalObject::getIntrinsicValue(cx, cx->global(), cx->names().getInternals,
                                          &getInternalsValue))
     {
-        return false;
+        return nullptr;
     }
     MOZ_ASSERT(getInternalsValue.isObject());
     MOZ_ASSERT(getInternalsValue.toObject().is<JSFunction>());
 
     InvokeArgs args(cx);
     if (!args.init(1))
-        return false;
+        return nullptr;
 
     args.setCallee(getInternalsValue);
     args.setThis(NullValue());
     args[0].setObject(*obj);
 
     if (!Invoke(cx, args))
-        return false;
-    internals.set(&args.rval().toObject());
-    return true;
+        return nullptr;
+
+    return &args.rval().toObject();
 }
 
 static bool
 equal(const char* s1, const char* s2)
 {
     return !strcmp(s1, s2);
 }
 
@@ -898,18 +898,18 @@ js::intl_availableCollations(JSContext* 
  * Returns a new UCollator with the locale and collation options
  * of the given Collator.
  */
 static UCollator*
 NewUCollator(JSContext* cx, HandleObject collator)
 {
     RootedValue value(cx);
 
-    RootedObject internals(cx);
-    if (!GetInternals(cx, collator, &internals))
+    RootedObject internals(cx, GetInternals(cx, collator));
+    if (!internals)
         return nullptr;
 
     if (!GetProperty(cx, internals, internals, cx->names().locale, &value))
         return nullptr;
     JSAutoByteString locale(cx, value.toString());
     if (!locale)
         return nullptr;
 
@@ -1363,18 +1363,18 @@ js::intl_numberingSystem(JSContext* cx, 
  * Returns a new UNumberFormat with the locale and number formatting options
  * of the given NumberFormat.
  */
 static UNumberFormat*
 NewUNumberFormat(JSContext* cx, HandleObject numberFormat)
 {
     RootedValue value(cx);
 
-    RootedObject internals(cx);
-    if (!GetInternals(cx, numberFormat, &internals))
+    RootedObject internals(cx, GetInternals(cx, numberFormat));
+    if (!internals)
        return nullptr;
 
     if (!GetProperty(cx, internals, internals, cx->names().locale, &value))
         return nullptr;
     JSAutoByteString locale(cx, value.toString());
     if (!locale)
         return nullptr;
 
@@ -1952,18 +1952,18 @@ js::intl_patternForSkeleton(JSContext* c
  * Returns a new UDateFormat with the locale and date-time formatting options
  * of the given DateTimeFormat.
  */
 static UDateFormat*
 NewUDateFormat(JSContext* cx, HandleObject dateTimeFormat)
 {
     RootedValue value(cx);
 
-    RootedObject internals(cx);
-    if (!GetInternals(cx, dateTimeFormat, &internals))
+    RootedObject internals(cx, GetInternals(cx, dateTimeFormat));
+    if (!internals)
        return nullptr;
 
     if (!GetProperty(cx, internals, internals, cx->names().locale, &value))
         return nullptr;
     JSAutoByteString locale(cx, value.toString());
     if (!locale)
         return nullptr;