From cf149139c62874029294ba31a0c222c5313f2d21 Mon Sep 17 00:00:00 2001 From: Andrew McCreight Date: Fri, 21 Mar 2014 09:43:40 -0700 Subject: [PATCH] Bug 975823, part 9 - No reason to store a pointer to the list, just store it inline. r=mcmanus --- .../src/nsStreamConverterService.cpp | 19 ++++++++----------- .../streamconv/src/nsStreamConverterService.h | 4 ++-- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/netwerk/streamconv/src/nsStreamConverterService.cpp b/netwerk/streamconv/src/nsStreamConverterService.cpp index d8b61a02591..14144d339d3 100644 --- a/netwerk/streamconv/src/nsStreamConverterService.cpp +++ b/netwerk/streamconv/src/nsStreamConverterService.cpp @@ -83,14 +83,11 @@ NS_IMPL_ISUPPORTS1(nsStreamConverterService, nsIStreamConverterService) //////////////////////////////////////////////////////////// // nsStreamConverterService methods nsStreamConverterService::nsStreamConverterService() - : mAdjacencyList (new nsObjectHashtable(nullptr, nullptr, - DeleteAdjacencyEntry, nullptr)) + : mAdjacencyList(nullptr, nullptr, DeleteAdjacencyEntry, nullptr) { } nsStreamConverterService::~nsStreamConverterService() { - NS_ASSERTION(mAdjacencyList, "init wasn't called, or the retval was ignored"); - delete mAdjacencyList; } // Builds the graph represented as an adjacency list (and built up in @@ -163,19 +160,19 @@ nsStreamConverterService::AddAdjacency(const char *aContractID) { // each MIME-type is represented as a key in our hashtable. nsCStringKey fromKey(fromStr); - SCTableData *fromEdges = (SCTableData*)mAdjacencyList->Get(&fromKey); + SCTableData *fromEdges = (SCTableData*)mAdjacencyList.Get(&fromKey); if (!fromEdges) { // There is no fromStr vertex, create one. SCTableData *data = new SCTableData(); - mAdjacencyList->Put(&fromKey, data); + mAdjacencyList.Put(&fromKey, data); fromEdges = data; } nsCStringKey toKey(toStr); - if (!mAdjacencyList->Get(&toKey)) { + if (!mAdjacencyList.Get(&toKey)) { // There is no toStr vertex, create one. SCTableData *data = new SCTableData(); - mAdjacencyList->Put(&toKey, data); + mAdjacencyList.Put(&toKey, data); } // Now we know the FROM and TO types are represented as keys in the hashtable. @@ -268,12 +265,12 @@ nsStreamConverterService::FindConverter(const char *aContractID, nsTArrayCount(); + int32_t vertexCount = mAdjacencyList.Count(); if (0 >= vertexCount) return NS_ERROR_FAILURE; // Create a corresponding color table for each vertex in the graph. nsObjectHashtable lBFSTable(nullptr, nullptr, DeleteBFSEntry, nullptr); - mAdjacencyList->Enumerate(InitBFSTable, &lBFSTable); + mAdjacencyList.Enumerate(InitBFSTable, &lBFSTable); NS_ASSERTION(lBFSTable.Count() == vertexCount, "strmconv BFS table init problem"); @@ -302,7 +299,7 @@ nsStreamConverterService::FindConverter(const char *aContractID, nsTArrayGet(currentHead); + SCTableData *data2 = (SCTableData*)mAdjacencyList.Get(currentHead); if (!data2) return NS_ERROR_FAILURE; // Get the state of the current head to calculate the distance of each diff --git a/netwerk/streamconv/src/nsStreamConverterService.h b/netwerk/streamconv/src/nsStreamConverterService.h index 626bd95acd5..9dbe0b0305f 100644 --- a/netwerk/streamconv/src/nsStreamConverterService.h +++ b/netwerk/streamconv/src/nsStreamConverterService.h @@ -8,9 +8,9 @@ #include "nsIStreamConverterService.h" +#include "nsHashtable.h" #include "nsTArrayForwardDeclare.h" -class nsObjectHashtable; class nsCString; class nsStreamConverterService : public nsIStreamConverterService { @@ -37,7 +37,7 @@ private: nsresult ParseFromTo(const char *aContractID, nsCString &aFromRes, nsCString &aToRes); // member variables - nsObjectHashtable *mAdjacencyList; + nsObjectHashtable mAdjacencyList; }; #endif // __nsstreamconverterservice__h___