Bug 1587905 - Remove useless variable 'bytesAllocated' declaration & assignation r=sfink
authorSylvestre Ledru <sledru@mozilla.com>
Fri, 11 Oct 2019 19:06:41 +0000
changeset 497296 daf34421eaa9757d83259fa98db64e475fa9949e
parent 497295 31d32668afb5e427b8d50ffca875ee7c7faa4a41
child 497297 f9209979c9bfe7c97d13f80fd507cd779af26fd8
push id36682
push userncsoregi@mozilla.com
push dateSat, 12 Oct 2019 09:52:03 +0000
treeherdermozilla-central@06ea2371f897 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssfink
bugs1587905
milestone71.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 1587905 - Remove useless variable 'bytesAllocated' declaration & assignation r=sfink Differential Revision: https://phabricator.services.mozilla.com/D48888
js/xpconnect/src/XPCJSRuntime.cpp
--- a/js/xpconnect/src/XPCJSRuntime.cpp
+++ b/js/xpconnect/src/XPCJSRuntime.cpp
@@ -2896,37 +2896,34 @@ static nsresult ReadSourceFromFilename(J
     rv = scriptStream->Read(ptr, PointerRangeSize(ptr, end), &bytesRead);
     if (NS_FAILED(rv)) {
       return rv;
     }
     MOZ_ASSERT(bytesRead > 0, "stream promised more bytes before EOF");
     ptr += bytesRead;
   }
 
-  size_t bytesAllocated;
   if (utf8Source) {
     // |buf| is already UTF-8, so we can directly return it.
-    *len = bytesAllocated = rawLen;
+    *len = rawLen;
     *utf8Source = buf.release();
   } else {
     MOZ_ASSERT(twoByteSource != nullptr);
 
     // |buf| can't be directly returned -- convert it to UTF-16.
 
     // On success this overwrites |*twoByteSource| and |*len|.
     rv = ScriptLoader::ConvertToUTF16(
         scriptChannel, reinterpret_cast<const unsigned char*>(buf.get()),
         rawLen, NS_LITERAL_STRING("UTF-8"), nullptr, *twoByteSource, *len);
     NS_ENSURE_SUCCESS(rv, rv);
 
     if (!*twoByteSource) {
       return NS_ERROR_FAILURE;
     }
-
-    bytesAllocated = *len * sizeof(char16_t);
   }
 
   return NS_OK;
 }
 
 // The JS engine calls this object's 'load' member function when it needs
 // the source for a chrome JS function. See the comment in the XPCJSRuntime
 // constructor.
@@ -3018,17 +3015,17 @@ js::UniquePtr<EdgeRange> ReflectorNode::
     return nullptr;
   }
   // UNWRAP_NON_WRAPPER_OBJECT assumes the object is completely initialized,
   // but ours may not be. Luckily, UnwrapDOMObjectToISupports checks for the
   // uninitialized case (and returns null if uninitialized), so we can use that
   // to guard against uninitialized objects.
   nsISupports* supp = UnwrapDOMObjectToISupports(&get());
   if (supp) {
-    JS::AutoSuppressGCAnalysis nogc; // bug 1582326
+    JS::AutoSuppressGCAnalysis nogc;  // bug 1582326
 
     nsINode* node;
     // UnwrapDOMObjectToISupports can only return non-null if its argument is
     // an actual DOM object, not a cross-compartment wrapper.
     if (NS_SUCCEEDED(UNWRAP_NON_WRAPPER_OBJECT(Node, &get(), node))) {
       char16_t* edgeName = nullptr;
       if (wantNames) {
         edgeName = NS_xstrdup(u"Reflected Node");
@@ -3279,36 +3276,36 @@ JSObject* XPCJSRuntime::GetUAWidgetScope
   MOZ_ASSERT(!nsContentUtils::IsSystemPrincipal(principal),
              "Running UA Widget in chrome");
 
   RootedObject scope(cx);
   do {
     RefPtr<BasePrincipal> key = BasePrincipal::Cast(principal);
     if (Principal2JSObjectMap::Ptr p = mUAWidgetScopeMap.lookup(key)) {
       scope = p->value();
-      break; // Need ~RefPtr to run, and potentially GC, before returning.
+      break;  // Need ~RefPtr to run, and potentially GC, before returning.
     }
 
     SandboxOptions options;
     options.sandboxName.AssignLiteral("UA Widget Scope");
     options.wantXrays = false;
     options.wantComponents = false;
     options.isUAWidgetScope = true;
 
     // Use an ExpandedPrincipal to create asymmetric security.
     MOZ_ASSERT(!nsContentUtils::IsExpandedPrincipal(principal));
     nsTArray<nsCOMPtr<nsIPrincipal>> principalAsArray(1);
     principalAsArray.AppendElement(principal);
     RefPtr<ExpandedPrincipal> ep = ExpandedPrincipal::Create(
-      principalAsArray, principal->OriginAttributesRef());
+        principalAsArray, principal->OriginAttributesRef());
 
     // Create the sandbox.
     RootedValue v(cx);
     nsresult rv = CreateSandboxObject(
-      cx, &v, static_cast<nsIExpandedPrincipal*>(ep), options);
+        cx, &v, static_cast<nsIExpandedPrincipal*>(ep), options);
     NS_ENSURE_SUCCESS(rv, nullptr);
     scope = &v.toObject();
 
     MOZ_ASSERT(xpc::IsInUAWidgetScope(js::UncheckedUnwrap(scope)));
 
     MOZ_ALWAYS_TRUE(mUAWidgetScopeMap.putNew(key, scope));
   } while (false);