Bug 1477086: Change LocalStorageManager::CreateOrigin()'s return type to nsAutoCString, to benefit from RVO and avoid needless string copying. r?smaug draft
authorDaniel Holbert <dholbert@cs.stanford.edu>
Thu, 19 Jul 2018 14:45:16 -0700
changeset 820564 619ee20e40ec7cb2f18ca16059ca56cbb1cce358
parent 820552 a2ecff8f25c842188469ec713f3942f0abea6d6c
push id116868
push userdholbert@mozilla.com
push dateThu, 19 Jul 2018 21:46:57 +0000
reviewerssmaug
bugs1477086
milestone63.0a1
Bug 1477086: Change LocalStorageManager::CreateOrigin()'s return type to nsAutoCString, to benefit from RVO and avoid needless string copying. r?smaug MozReview-Commit-ID: 1IALP0xgOqp
dom/storage/LocalStorageManager.cpp
dom/storage/LocalStorageManager.h
--- a/dom/storage/LocalStorageManager.cpp
+++ b/dom/storage/LocalStorageManager.cpp
@@ -125,17 +125,17 @@ CreateQuotaDBKey(nsIPrincipal* aPrincipa
   aKey.Append(subdomainsDBKey);
 
   return NS_OK;
 }
 
 } // namespace
 
 // static
-nsCString
+nsAutoCString
 LocalStorageManager::CreateOrigin(const nsACString& aOriginSuffix,
                                   const nsACString& aOriginNoSuffix)
 {
   // Note: some hard-coded sqlite statements are dependent on the format this
   // method returns.  Changing this without updating those sqlite statements
   // will cause malfunction.
 
   nsAutoCString scope;
--- a/dom/storage/LocalStorageManager.h
+++ b/dom/storage/LocalStorageManager.h
@@ -40,18 +40,18 @@ public:
   // Gets (but not ensures) cache for the given scope
   LocalStorageCache* GetCache(const nsACString& aOriginSuffix,
                               const nsACString& aOriginNoSuffix);
 
   // Returns object keeping usage cache for the scope.
   already_AddRefed<StorageUsage>
   GetOriginUsage(const nsACString& aOriginNoSuffix);
 
-  static nsCString CreateOrigin(const nsACString& aOriginSuffix,
-                                const nsACString& aOriginNoSuffix);
+  static nsAutoCString CreateOrigin(const nsACString& aOriginSuffix,
+                                    const nsACString& aOriginNoSuffix);
 
 private:
   ~LocalStorageManager();
 
   // StorageObserverSink, handler to various chrome clearing notification
   nsresult Observe(const char* aTopic,
                    const nsAString& aOriginAttributesPattern,
                    const nsACString& aOriginScope) override;