Bug 1186787 (part 1) - Replace nsBaseHashtable::EnumerateRead() calls in chrome/ with iterators. r=froydnj.
authorNicholas Nethercote <nnethercote@mozilla.com>
Tue, 17 Nov 2015 17:58:34 -0800
changeset 273067 401949c4008ed49464a7fd13781bee79b432a0b4
parent 273066 84d1c56d6983f1acb9f09bf29c2b45b9183e944b
child 273068 4e0a66f7b693d055ef52c5b17d55cb117d6296b0
push id29693
push usercbook@mozilla.com
push dateWed, 18 Nov 2015 13:50:33 +0000
treeherderautoland@1d6155d7e6c9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1186787
milestone45.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 1186787 (part 1) - Replace nsBaseHashtable::EnumerateRead() calls in chrome/ with iterators. r=froydnj.
chrome/nsChromeRegistryChrome.cpp
chrome/nsChromeRegistryChrome.h
--- a/chrome/nsChromeRegistryChrome.cpp
+++ b/chrome/nsChromeRegistryChrome.cpp
@@ -411,35 +411,30 @@ EnumerateOverride(nsIURI* aURIKey,
 
   OverrideMapping override = {
     chromeURI, overrideURI
   };
   overrides->AppendElement(override);
   return (PLDHashOperator)PL_DHASH_NEXT;
 }
 
-struct EnumerationArgs
-{
-  InfallibleTArray<ChromePackage>& packages;
-  const nsCString& selectedLocale;
-  const nsCString& selectedSkin;
-};
-
 void
 nsChromeRegistryChrome::SendRegisteredChrome(
     mozilla::dom::PContentParent* aParent)
 {
   InfallibleTArray<ChromePackage> packages;
   InfallibleTArray<SubstitutionMapping> resources;
   InfallibleTArray<OverrideMapping> overrides;
 
-  EnumerationArgs args = {
-    packages, mSelectedLocale, mSelectedSkin
-  };
-  mPackagesHash.EnumerateRead(CollectPackages, &args);
+  for (auto iter = mPackagesHash.Iter(); !iter.Done(); iter.Next()) {
+    ChromePackage chromePackage;
+    ChromePackageFromPackageEntry(iter.Key(), iter.UserData(), &chromePackage,
+                                  mSelectedLocale, mSelectedSkin);
+    packages.AppendElement(chromePackage);
+  }
 
   // If we were passed a parent then a new child process has been created and
   // has requested all of the chrome so send it the resources too. Otherwise
   // resource mappings are sent by the resource protocol handler dynamically.
   if (aParent) {
     nsCOMPtr<nsIIOService> io (do_GetIOService());
     NS_ENSURE_TRUE_VOID(io);
 
@@ -485,30 +480,16 @@ nsChromeRegistryChrome::ChromePackageFro
                                          nsProviderArray::LOCALE),
                aChromePackage->localeBaseURI);
   SerializeURI(aPackage->skins.GetBase(aSelectedSkin, nsProviderArray::ANY),
                aChromePackage->skinBaseURI);
   aChromePackage->package = aPackageName;
   aChromePackage->flags = aPackage->flags;
 }
 
-PLDHashOperator
-nsChromeRegistryChrome::CollectPackages(const nsACString &aKey,
-                                        PackageEntry *package,
-                                        void *arg)
-{
-  EnumerationArgs* args = static_cast<EnumerationArgs*>(arg);
-
-  ChromePackage chromePackage;
-  ChromePackageFromPackageEntry(aKey, package, &chromePackage,
-                                args->selectedLocale, args->selectedSkin);
-  args->packages.AppendElement(chromePackage);
-  return PL_DHASH_NEXT;
-}
-
 static bool
 CanLoadResource(nsIURI* aResourceURI)
 {
   bool isLocalResource = false;
   (void)NS_URIChainHasFlags(aResourceURI,
                             nsIProtocolHandler::URI_IS_LOCAL_RESOURCE,
                             &isLocalResource);
   return isLocalResource;
--- a/chrome/nsChromeRegistryChrome.h
+++ b/chrome/nsChromeRegistryChrome.h
@@ -54,19 +54,16 @@ class nsChromeRegistryChrome : public ns
 
  private:
   struct PackageEntry;
   static void ChromePackageFromPackageEntry(const nsACString& aPackageName,
                                             PackageEntry* aPackage,
                                             ChromePackage* aChromePackage,
                                             const nsCString& aSelectedLocale,
                                             const nsCString& aSelectedSkin);
-  static PLDHashOperator CollectPackages(const nsACString &aKey,
-                                         PackageEntry *package,
-                                         void *arg);
 
   nsresult OverrideLocalePackage(const nsACString& aPackage,
                                  nsACString& aOverride);
   nsresult SelectLocaleFromPref(nsIPrefBranch* prefs);
   nsresult UpdateSelectedLocale() override;
   nsIURI* GetBaseURIFromPackage(const nsCString& aPackage,
                                  const nsCString& aProvider,
                                  const nsCString& aPath) override;