Bug 975823, part 8 - Inline nsStreamConverterService::Init which is now infallible. r=mcmanus

This commit is contained in:
Andrew McCreight 2014-03-21 09:43:40 -07:00
parent 04be8960b7
commit 17d721b9aa
2 changed files with 12 additions and 23 deletions

View File

@ -52,6 +52,13 @@ struct BFSState {
// Adjacency list data class.
typedef nsCOMArray<nsIAtom> 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;
}

View File

@ -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<nsCString> **aEdgeList);