зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1168007 (part 9) - Use PLDHashTable2 in nsCacheEntry. r=froydnj.
It's not entirely clear if it's necessary to call Clear() in nsCacheEntryHashTable::Init(). There is lots of inheritance around this code and the calling patterns of Init() and Shutdown() aren't clear. Better safe than sorry. --HG-- extra : rebase_source : e21764b8cbdf7cda7894651e57653e24ac7e1502
This commit is contained in:
Родитель
a84d4cd609
Коммит
f88934c4f6
|
@ -385,7 +385,8 @@ nsCacheEntryHashTable::ops =
|
|||
|
||||
|
||||
nsCacheEntryHashTable::nsCacheEntryHashTable()
|
||||
: initialized(false)
|
||||
: table(&ops, sizeof(nsCacheEntryHashTableEntry), kInitialTableLength)
|
||||
, initialized(false)
|
||||
{
|
||||
MOZ_COUNT_CTOR(nsCacheEntryHashTable);
|
||||
}
|
||||
|
@ -399,19 +400,18 @@ nsCacheEntryHashTable::~nsCacheEntryHashTable()
|
|||
}
|
||||
|
||||
|
||||
nsresult
|
||||
void
|
||||
nsCacheEntryHashTable::Init()
|
||||
{
|
||||
PL_DHashTableInit(&table, &ops, sizeof(nsCacheEntryHashTableEntry), 256);
|
||||
table.ClearAndPrepareForLength(kInitialTableLength);
|
||||
initialized = true;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
nsCacheEntryHashTable::Shutdown()
|
||||
{
|
||||
if (initialized) {
|
||||
PL_DHashTableFinish(&table);
|
||||
table.ClearAndPrepareForLength(kInitialTableLength);
|
||||
initialized = false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -267,13 +267,13 @@ public:
|
|||
nsCacheEntryHashTable();
|
||||
~nsCacheEntryHashTable();
|
||||
|
||||
nsresult Init();
|
||||
void Init();
|
||||
void Shutdown();
|
||||
|
||||
nsCacheEntry *GetEntry( const nsCString * key);
|
||||
nsresult AddEntry( nsCacheEntry *entry);
|
||||
void RemoveEntry( nsCacheEntry *entry);
|
||||
|
||||
|
||||
void VisitEntries( PLDHashEnumerator etor, void *arg);
|
||||
|
||||
private:
|
||||
|
@ -302,11 +302,13 @@ private:
|
|||
PLDHashEntryHdr * hdr,
|
||||
uint32_t number,
|
||||
void * arg);
|
||||
|
||||
|
||||
// member variables
|
||||
static const PLDHashTableOps ops;
|
||||
PLDHashTable table;
|
||||
PLDHashTable2 table;
|
||||
bool initialized;
|
||||
|
||||
static const uint32_t kInitialTableLength = 256;
|
||||
};
|
||||
|
||||
#endif // _nsCacheEntry_h_
|
||||
|
|
|
@ -1153,8 +1153,7 @@ nsCacheService::Init()
|
|||
}
|
||||
|
||||
// initialize hashtable for active cache entries
|
||||
rv = mActiveEntries.Init();
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
mActiveEntries.Init();
|
||||
|
||||
// create profile/preference observer
|
||||
if (!mObserver) {
|
||||
|
|
|
@ -55,9 +55,9 @@ nsMemoryCacheDevice::Init()
|
|||
{
|
||||
if (mInitialized) return NS_ERROR_ALREADY_INITIALIZED;
|
||||
|
||||
nsresult rv = mMemCacheEntries.Init();
|
||||
mInitialized = NS_SUCCEEDED(rv);
|
||||
return rv;
|
||||
mMemCacheEntries.Init();
|
||||
mInitialized = true;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче