Bug 1225407 - Replace nsInterfaceHashtable::EnumerateRead() call in SubstitutingProtocolHandler with an iterator. r=michal
authorMike Hommey <mh+mozilla@glandium.org>
Tue, 17 Nov 2015 16:38:54 +0900
changeset 273168 082fd246bfd39fafdc66dcc4e68cf7f97b1aaf6c
parent 273167 f20f90d8cbbb01061d3f12efbd613170456b7d69
child 273169 aeebc4c5fba749ff96936ce56916f7cea604e1a4
push id68191
push usermh@glandium.org
push dateWed, 18 Nov 2015 23:07:16 +0000
treeherdermozilla-inbound@7b54175c1241 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmichal
bugs1225407
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 1225407 - Replace nsInterfaceHashtable::EnumerateRead() call in SubstitutingProtocolHandler with an iterator. r=michal
netwerk/protocol/res/SubstitutingProtocolHandler.cpp
--- a/netwerk/protocol/res/SubstitutingProtocolHandler.cpp
+++ b/netwerk/protocol/res/SubstitutingProtocolHandler.cpp
@@ -106,46 +106,29 @@ SubstitutingProtocolHandler::ConstructIn
   mIOService = do_GetIOService(&rv);
   MOZ_RELEASE_ASSERT(NS_SUCCEEDED(rv) && mIOService);
 }
 
 //
 // IPC marshalling.
 //
 
-struct EnumerateSubstitutionArg
-{
-  EnumerateSubstitutionArg(nsCString& aScheme, nsTArray<SubstitutionMapping>& aMappings)
-    : mScheme(aScheme), mMappings(aMappings) {}
-  nsCString& mScheme;
-  nsTArray<SubstitutionMapping>& mMappings;
-};
-
-static PLDHashOperator
-EnumerateSubstitution(const nsACString& aKey,
-                      nsIURI* aURI,
-                      void* aArg)
-{
-  auto arg = static_cast<EnumerateSubstitutionArg*>(aArg);
-  SerializedURI uri;
-  if (aURI) {
-    aURI->GetSpec(uri.spec);
-    aURI->GetOriginCharset(uri.charset);
-  }
-
-  SubstitutionMapping substitution = { arg->mScheme, nsCString(aKey), uri };
-  arg->mMappings.AppendElement(substitution);
-  return (PLDHashOperator)PL_DHASH_NEXT;
-}
-
 void
 SubstitutingProtocolHandler::CollectSubstitutions(InfallibleTArray<SubstitutionMapping>& aMappings)
 {
-  EnumerateSubstitutionArg arg(mScheme, aMappings);
-  mSubstitutions.EnumerateRead(&EnumerateSubstitution, &arg);
+  for (auto iter = mSubstitutions.ConstIter(); !iter.Done(); iter.Next()) {
+    nsCOMPtr<nsIURI> uri = iter.Data();
+    SerializedURI serialized;
+    if (uri) {
+      uri->GetSpec(serialized.spec);
+      uri->GetOriginCharset(serialized.charset);
+    }
+    SubstitutionMapping substitution = { mScheme, nsCString(iter.Key()), serialized };
+    aMappings.AppendElement(substitution);
+  }
 }
 
 void
 SubstitutingProtocolHandler::SendSubstitution(const nsACString& aRoot, nsIURI* aBaseURI)
 {
   if (GeckoProcessType_Content == XRE_GetProcessType()) {
     return;
   }