From 17d721b9aa8514fb1ed24f8292ffad99b57fc6d3 Mon Sep 17 00:00:00 2001 From: Andrew McCreight Date: Fri, 21 Mar 2014 09:43:40 -0700 Subject: [PATCH] Bug 975823, part 8 - Inline nsStreamConverterService::Init which is now infallible. r=mcmanus --- .../src/nsStreamConverterService.cpp | 32 +++++++------------ .../streamconv/src/nsStreamConverterService.h | 3 -- 2 files changed, 12 insertions(+), 23 deletions(-) diff --git a/netwerk/streamconv/src/nsStreamConverterService.cpp b/netwerk/streamconv/src/nsStreamConverterService.cpp index 6c888eecc99f..d8b61a02591f 100644 --- a/netwerk/streamconv/src/nsStreamConverterService.cpp +++ b/netwerk/streamconv/src/nsStreamConverterService.cpp @@ -52,6 +52,13 @@ struct BFSState { // Adjacency list data class. typedef nsCOMArray SCTableData; +// Delete all the entries in the adjacency list +static bool DeleteAdjacencyEntry(nsHashKey *aKey, void *aData, void* closure) { + SCTableData *entry = (SCTableData*)aData; + delete entry; + return true; +} + // BFS hashtable data class. struct BFSTableData { nsCStringKey *key; @@ -75,7 +82,10 @@ NS_IMPL_ISUPPORTS1(nsStreamConverterService, nsIStreamConverterService) //////////////////////////////////////////////////////////// // nsStreamConverterService methods -nsStreamConverterService::nsStreamConverterService() : mAdjacencyList(nullptr) { +nsStreamConverterService::nsStreamConverterService() + : mAdjacencyList (new nsObjectHashtable(nullptr, nullptr, + DeleteAdjacencyEntry, nullptr)) +{ } nsStreamConverterService::~nsStreamConverterService() { @@ -83,20 +93,6 @@ nsStreamConverterService::~nsStreamConverterService() { delete mAdjacencyList; } -// Delete all the entries in the adjacency list -static bool DeleteAdjacencyEntry(nsHashKey *aKey, void *aData, void* closure) { - SCTableData *entry = (SCTableData*)aData; - delete entry; - return true; -} - -nsresult -nsStreamConverterService::Init() { - mAdjacencyList = new nsObjectHashtable(nullptr, nullptr, - DeleteAdjacencyEntry, nullptr); - return NS_OK; -} - // Builds the graph represented as an adjacency list (and built up in // memory using an nsObjectHashtable and nsISupportsArray combination). // @@ -637,11 +633,7 @@ NS_NewStreamConv(nsStreamConverterService** aStreamConv) if (!aStreamConv) return NS_ERROR_NULL_POINTER; *aStreamConv = new nsStreamConverterService(); - NS_ADDREF(*aStreamConv); - nsresult rv = (*aStreamConv)->Init(); - if (NS_FAILED(rv)) - NS_RELEASE(*aStreamConv); - return rv; + return NS_OK; } diff --git a/netwerk/streamconv/src/nsStreamConverterService.h b/netwerk/streamconv/src/nsStreamConverterService.h index bbda445e648a..626bd95acd55 100644 --- a/netwerk/streamconv/src/nsStreamConverterService.h +++ b/netwerk/streamconv/src/nsStreamConverterService.h @@ -29,9 +29,6 @@ public: nsStreamConverterService(); virtual ~nsStreamConverterService(); - // Initialization routine. Must be called after this object is constructed. - nsresult Init(); - private: // Responsible for finding a converter for the given MIME-type. nsresult FindConverter(const char *aContractID, nsTArray **aEdgeList);