From 05bb883ae639da24f290a1f0a7bab72ff924555a Mon Sep 17 00:00:00 2001 From: Mike Hommey Date: Tue, 17 Nov 2015 16:38:54 +0900 Subject: [PATCH] Bug 1225407 - Replace nsInterfaceHashtable::EnumerateRead() call in SubstitutingProtocolHandler with an iterator. r=michal --- .../res/SubstitutingProtocolHandler.cpp | 37 +++++-------------- 1 file changed, 10 insertions(+), 27 deletions(-) diff --git a/netwerk/protocol/res/SubstitutingProtocolHandler.cpp b/netwerk/protocol/res/SubstitutingProtocolHandler.cpp index e9f4b5a75dc0..96303f22c079 100644 --- a/netwerk/protocol/res/SubstitutingProtocolHandler.cpp +++ b/netwerk/protocol/res/SubstitutingProtocolHandler.cpp @@ -111,36 +111,19 @@ SubstitutingProtocolHandler::ConstructInternal() // IPC marshalling. // -struct EnumerateSubstitutionArg -{ - EnumerateSubstitutionArg(nsCString& aScheme, nsTArray& aMappings) - : mScheme(aScheme), mMappings(aMappings) {} - nsCString& mScheme; - nsTArray& mMappings; -}; - -static PLDHashOperator -EnumerateSubstitution(const nsACString& aKey, - nsIURI* aURI, - void* aArg) -{ - auto arg = static_cast(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& aMappings) { - EnumerateSubstitutionArg arg(mScheme, aMappings); - mSubstitutions.EnumerateRead(&EnumerateSubstitution, &arg); + for (auto iter = mSubstitutions.ConstIter(); !iter.Done(); iter.Next()) { + nsCOMPtr 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