mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-29 15:52:07 +00:00
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:
parent
f88934c4f6
commit
71674e097c
12
netwerk/cache/nsDiskCacheBinding.cpp
vendored
12
netwerk/cache/nsDiskCacheBinding.cpp
vendored
@ -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;
|
||||
}
|
||||
}
|
||||
|
6
netwerk/cache/nsDiskCacheBinding.h
vendored
6
netwerk/cache/nsDiskCacheBinding.h
vendored
@ -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_ */
|
||||
|
6
netwerk/cache/nsDiskCacheDevice.cpp
vendored
6
netwerk/cache/nsDiskCacheDevice.cpp
vendored
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user