Bug 1521595 - Reduce the amount of memory allocations in nsContentUtils::Get*Origin(); r=baku
authorEhsan Akhgari <ehsan@mozilla.com>
Tue, 22 Jan 2019 18:02:41 +0000
changeset 514851 b2066b96bd8fcda814e7438c81880b59615bde1e
parent 514850 828fe91e878b700d0135adb3f45a9554694e4498
child 514852 36b36b5cdab6c75c1cfd7e0e7c4784c297c2efa2
push id1953
push userffxbld-merge
push dateMon, 11 Mar 2019 12:10:20 +0000
treeherdermozilla-release@9c35dcbaa899 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbaku
bugs1521595
milestone66.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 1521595 - Reduce the amount of memory allocations in nsContentUtils::Get*Origin(); r=baku Differential Revision: https://phabricator.services.mozilla.com/D17154
dom/base/nsContentUtils.cpp
--- a/dom/base/nsContentUtils.cpp
+++ b/dom/base/nsContentUtils.cpp
@@ -5840,29 +5840,29 @@ nsresult nsContentUtils::GetASCIIOrigin(
     return GetASCIIOrigin(uri, aOrigin);
   }
 
   aOrigin.Truncate();
 
   nsCOMPtr<nsIURI> uri = NS_GetInnermostURI(aURI);
   NS_ENSURE_TRUE(uri, NS_ERROR_UNEXPECTED);
 
-  nsCString host;
+  nsAutoCString host;
   rv = uri->GetAsciiHost(host);
 
   if (NS_SUCCEEDED(rv) && !host.IsEmpty()) {
-    nsCString scheme;
+    nsAutoCString scheme;
     rv = uri->GetScheme(scheme);
     NS_ENSURE_SUCCESS(rv, rv);
 
     int32_t port = -1;
     uri->GetPort(&port);
     if (port != -1 && port == NS_GetDefaultPort(scheme.get())) port = -1;
 
-    nsCString hostPort;
+    nsAutoCString hostPort;
     rv = NS_GenerateHostPort(host, port, hostPort);
     NS_ENSURE_SUCCESS(rv, rv);
 
     aOrigin = scheme + NS_LITERAL_CSTRING("://") + hostPort;
   } else {
     aOrigin.AssignLiteral("null");
   }
 
@@ -5927,29 +5927,29 @@ nsresult nsContentUtils::GetUTFOrigin(ns
     return GetUTFOrigin(uri, aOrigin);
   }
 
   aOrigin.Truncate();
 
   nsCOMPtr<nsIURI> uri = NS_GetInnermostURI(aURI);
   NS_ENSURE_TRUE(uri, NS_ERROR_UNEXPECTED);
 
-  nsCString host;
+  nsAutoCString host;
   rv = uri->GetHost(host);
 
   if (NS_SUCCEEDED(rv) && !host.IsEmpty()) {
-    nsCString scheme;
+    nsAutoCString scheme;
     rv = uri->GetScheme(scheme);
     NS_ENSURE_SUCCESS(rv, rv);
 
     int32_t port = -1;
     uri->GetPort(&port);
     if (port != -1 && port == NS_GetDefaultPort(scheme.get())) port = -1;
 
-    nsCString hostPort;
+    nsAutoCString hostPort;
     rv = NS_GenerateHostPort(host, port, hostPort);
     NS_ENSURE_SUCCESS(rv, rv);
 
     aOrigin =
         NS_ConvertUTF8toUTF16(scheme + NS_LITERAL_CSTRING("://") + hostPort);
   } else {
     aOrigin.AssignLiteral("null");
   }