Bug 1340928 (part 15) - Inline and remove ToJSObject(). r=mstange.
authorNicholas Nethercote <nnethercote@mozilla.com>
Wed, 22 Feb 2017 13:42:14 +1100
changeset 373487 494906dbf2d99146cc25c27f8cb51f84c6fe4759
parent 373486 d0d5dcaa2c361b2b5bd66f9ff06292098305c726
child 373488 c94cfb6232488d62ff84ed32c021afb5925040d0
push id10863
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 23:02:23 +0000
treeherdermozilla-aurora@0931190cd725 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmstange
bugs1340928
milestone54.0a1
Bug 1340928 (part 15) - Inline and remove ToJSObject(). r=mstange. It has a single call site.
tools/profiler/core/platform.cpp
--- a/tools/profiler/core/platform.cpp
+++ b/tools/profiler/core/platform.cpp
@@ -1176,29 +1176,16 @@ StreamJSON(SpliceableJSONWriter& aWriter
 UniquePtr<char[]>
 ToJSON(double aSinceTime)
 {
   SpliceableChunkedJSONWriter b;
   StreamJSON(b, aSinceTime);
   return b.WriteFunc()->CopyData();
 }
 
-static JSObject*
-ToJSObject(JSContext* aCx, double aSinceTime)
-{
-  JS::RootedValue val(aCx);
-  {
-    UniquePtr<char[]> buf = ToJSON(aSinceTime);
-    NS_ConvertUTF8toUTF16 js_string(nsDependentCString(buf.get()));
-    MOZ_ALWAYS_TRUE(JS_ParseJSON(aCx, static_cast<const char16_t*>(js_string.get()),
-                                 js_string.Length(), &val));
-  }
-  return &val.toObject();
-}
-
 // END saving/streaming code
 ////////////////////////////////////////////////////////////////////////
 
 ProfilerMarker::ProfilerMarker(const char* aMarkerName,
                                ProfilerMarkerPayload* aPayload,
                                double aTime)
   : mMarkerName(strdup(aMarkerName))
   , mPayload(aPayload)
@@ -1721,17 +1708,24 @@ JSObject*
 profiler_get_profile_jsobject(JSContext *aCx, double aSinceTime)
 {
   MOZ_RELEASE_ASSERT(NS_IsMainThread());
 
   if (!gSampler) {
     return nullptr;
   }
 
-  return ToJSObject(aCx, aSinceTime);
+  JS::RootedValue val(aCx);
+  {
+    UniquePtr<char[]> buf = ToJSON(aSinceTime);
+    NS_ConvertUTF8toUTF16 js_string(nsDependentCString(buf.get()));
+    auto buf16 = static_cast<const char16_t*>(js_string.get());
+    MOZ_ALWAYS_TRUE(JS_ParseJSON(aCx, buf16, js_string.Length(), &val));
+  }
+  return &val.toObject();
 }
 
 void
 profiler_get_profile_jsobject_async(double aSinceTime,
                                     mozilla::dom::Promise* aPromise)
 {
   MOZ_RELEASE_ASSERT(NS_IsMainThread());