Bug 1168007 (part 10) - Use PLDHashTable2 in nsDiskCacheBindery. r=froydnj.

Like the last patch, the Clear() call in nsDiskCacheBindery::Init() is
cautious.

--HG--
extra : rebase_source : ebf8fddcf455dddf43be843cac9c119cdc954ce7
This commit is contained in:
Nicholas Nethercote 2015-05-18 21:52:14 -07:00
parent f88934c4f6
commit 71674e097c
3 changed files with 11 additions and 13 deletions

View File

@ -132,7 +132,8 @@ const PLDHashTableOps nsDiskCacheBindery::ops =
nsDiskCacheBindery::nsDiskCacheBindery()
: initialized(false)
: table(&ops, sizeof(HashTableEntry), kInitialTableLength)
, initialized(false)
{
}
@ -143,21 +144,18 @@ nsDiskCacheBindery::~nsDiskCacheBindery()
}
nsresult
void
nsDiskCacheBindery::Init()
{
nsresult rv = NS_OK;
PL_DHashTableInit(&table, &ops, sizeof(HashTableEntry), 0);
table.ClearAndPrepareForLength(kInitialTableLength);
initialized = true;
return rv;
}
void
nsDiskCacheBindery::Reset()
{
if (initialized) {
PL_DHashTableFinish(&table);
table.ClearAndPrepareForLength(kInitialTableLength);
initialized = false;
}
}

View File

@ -97,7 +97,7 @@ public:
nsDiskCacheBindery();
~nsDiskCacheBindery();
nsresult Init();
void Init();
void Reset();
nsDiskCacheBinding * CreateBinding(nsCacheEntry * entry,
@ -114,8 +114,10 @@ private:
// member variables
static const PLDHashTableOps ops;
PLDHashTable table;
PLDHashTable2 table;
bool initialized;
static const uint32_t kInitialTableLength = 0;
};
#endif /* _nsDiskCacheBinding_h_ */

View File

@ -384,13 +384,11 @@ nsDiskCacheDevice::Init()
NS_ERROR("Disk cache already initialized!");
return NS_ERROR_UNEXPECTED;
}
if (!mCacheDirectory)
return NS_ERROR_FAILURE;
rv = mBindery.Init();
if (NS_FAILED(rv))
return rv;
mBindery.Init();
// Open Disk Cache
rv = OpenDiskCache();