зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1170416 (part 1) - Remove PL_DHashTable{Init,Finish,Destroy){} and PL_NewDHashTable(). r=froydnj.
--HG-- extra : rebase_source : 8263b1fecd550ba6356f99537cdaf439c24680ae
This commit is contained in:
Родитель
43c1225280
Коммит
54766ec371
|
@ -38,7 +38,7 @@
|
|||
* allowed (and therefore the level is 0 or 1, depending on whether they
|
||||
* incremented it).
|
||||
*
|
||||
* Only PL_DHashTableFinish needs to allow this special value.
|
||||
* Only Finish() needs to allow this special value.
|
||||
*/
|
||||
#define IMMUTABLE_RECURSION_LEVEL UINT32_MAX
|
||||
|
||||
|
@ -169,22 +169,6 @@ SizeOfEntryStore(uint32_t aCapacity, uint32_t aEntrySize, uint32_t* aNbytes)
|
|||
return uint64_t(*aNbytes) == nbytes64; // returns false on overflow
|
||||
}
|
||||
|
||||
PLDHashTable*
|
||||
PL_NewDHashTable(const PLDHashTableOps* aOps, uint32_t aEntrySize,
|
||||
uint32_t aLength)
|
||||
{
|
||||
PLDHashTable* table = new PLDHashTable();
|
||||
PL_DHashTableInit(table, aOps, aEntrySize, aLength);
|
||||
return table;
|
||||
}
|
||||
|
||||
void
|
||||
PL_DHashTableDestroy(PLDHashTable* aTable)
|
||||
{
|
||||
PL_DHashTableFinish(aTable);
|
||||
delete aTable;
|
||||
}
|
||||
|
||||
/*
|
||||
* Compute max and min load numbers (entry counts). We have a secondary max
|
||||
* that allows us to overload a table reasonably if it cannot be grown further
|
||||
|
@ -259,20 +243,6 @@ PLDHashTable::Init(const PLDHashTableOps* aOps,
|
|||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
PL_DHashTableInit(PLDHashTable* aTable, const PLDHashTableOps* aOps,
|
||||
uint32_t aEntrySize, uint32_t aLength)
|
||||
{
|
||||
aTable->Init(aOps, aEntrySize, aLength);
|
||||
}
|
||||
|
||||
void
|
||||
PL_DHashTableInit(PLDHashTable2* aTable, const PLDHashTableOps* aOps,
|
||||
uint32_t aEntrySize, uint32_t aLength)
|
||||
{
|
||||
aTable->Init(aOps, aEntrySize, aLength);
|
||||
}
|
||||
|
||||
PLDHashTable2::PLDHashTable2(const PLDHashTableOps* aOps, uint32_t aEntrySize,
|
||||
uint32_t aLength)
|
||||
: PLDHashTable()
|
||||
|
@ -383,18 +353,6 @@ PLDHashTable::Finish()
|
|||
mEntryStore = nullptr;
|
||||
}
|
||||
|
||||
void
|
||||
PL_DHashTableFinish(PLDHashTable* aTable)
|
||||
{
|
||||
aTable->Finish();
|
||||
}
|
||||
|
||||
void
|
||||
PL_DHashTableFinish(PLDHashTable2* aTable)
|
||||
{
|
||||
aTable->Finish();
|
||||
}
|
||||
|
||||
PLDHashTable2::~PLDHashTable2()
|
||||
{
|
||||
PLDHashTable::Finish();
|
||||
|
|
|
@ -254,10 +254,6 @@ public:
|
|||
uint32_t EntryCount() const { return mEntryCount; }
|
||||
uint32_t Generation() const { return mGeneration; }
|
||||
|
||||
void Init(const PLDHashTableOps* aOps, uint32_t aEntrySize, uint32_t aLength);
|
||||
|
||||
void Finish();
|
||||
|
||||
PLDHashEntryHdr* Search(const void* aKey);
|
||||
PLDHashEntryHdr* Add(const void* aKey, const mozilla::fallible_t&);
|
||||
PLDHashEntryHdr* Add(const void* aKey);
|
||||
|
@ -322,6 +318,9 @@ private:
|
|||
|
||||
PLDHashNumber ComputeKeyHash(const void* aKey);
|
||||
|
||||
void Init(const PLDHashTableOps* aOps, uint32_t aEntrySize, uint32_t aLength);
|
||||
void Finish();
|
||||
|
||||
enum SearchReason { ForSearchOrRemove, ForAdd };
|
||||
|
||||
template <SearchReason Reason>
|
||||
|
@ -350,6 +349,14 @@ private:
|
|||
class PLDHashTable2 : public PLDHashTable
|
||||
{
|
||||
public:
|
||||
// Initialize the table with |aOps| and |aEntrySize|. The table's initial
|
||||
// capacity is chosen such that |aLength| elements can be inserted without
|
||||
// rehashing; if |aLength| is a power-of-two, this capacity will be
|
||||
// |2*length|. However, because entry storage is allocated lazily, this
|
||||
// initial capacity won't be relevant until the first element is added; prior
|
||||
// to that the capacity will be zero.
|
||||
//
|
||||
// This will crash if |aEntrySize| and/or |aLength| are too large.
|
||||
PLDHashTable2(const PLDHashTableOps* aOps, uint32_t aEntrySize,
|
||||
uint32_t aLength = PL_DHASH_DEFAULT_INITIAL_LENGTH);
|
||||
|
||||
|
@ -365,13 +372,6 @@ public:
|
|||
|
||||
~PLDHashTable2();
|
||||
|
||||
void Init(const PLDHashTableOps* aOps, uint32_t aEntrySize, uint32_t aLength)
|
||||
{
|
||||
MOZ_CRASH("PLDHashTable2::Init()");
|
||||
}
|
||||
|
||||
void Finish() { MOZ_CRASH("PLDHashTable2::Finish()"); }
|
||||
|
||||
// This function is equivalent to
|
||||
// ClearAndPrepareForLength(PL_DHASH_DEFAULT_INITIAL_LENGTH).
|
||||
void Clear();
|
||||
|
@ -504,46 +504,6 @@ void PL_DHashFreeStringKey(PLDHashTable* aTable, PLDHashEntryHdr* aEntry);
|
|||
*/
|
||||
const PLDHashTableOps* PL_DHashGetStubOps(void);
|
||||
|
||||
/*
|
||||
* Dynamically allocate a new PLDHashTable, initialize it using
|
||||
* PL_DHashTableInit, and return its address. Never returns null.
|
||||
*/
|
||||
PLDHashTable* PL_NewDHashTable(
|
||||
const PLDHashTableOps* aOps, uint32_t aEntrySize,
|
||||
uint32_t aLength = PL_DHASH_DEFAULT_INITIAL_LENGTH);
|
||||
|
||||
/*
|
||||
* Free |aTable|'s entry storage and |aTable| itself (both via
|
||||
* aTable->mOps->freeTable). Use this function to destroy a PLDHashTable that
|
||||
* was allocated on the heap via PL_NewDHashTable().
|
||||
*/
|
||||
void PL_DHashTableDestroy(PLDHashTable* aTable);
|
||||
|
||||
/*
|
||||
* Initialize aTable with aOps and aEntrySize. The table's initial capacity
|
||||
* will be chosen such that |aLength| elements can be inserted without
|
||||
* rehashing; if |aLength| is a power-of-two, this capacity will be |2*length|.
|
||||
* However, because entry storage is allocated lazily, this initial capacity
|
||||
* won't be relevant until the first element is added; prior to that the
|
||||
* capacity will be zero.
|
||||
*
|
||||
* This function will crash if |aEntrySize| and/or |aLength| are too large.
|
||||
*/
|
||||
void PL_DHashTableInit(
|
||||
PLDHashTable* aTable, const PLDHashTableOps* aOps,
|
||||
uint32_t aEntrySize, uint32_t aLength = PL_DHASH_DEFAULT_INITIAL_LENGTH);
|
||||
void PL_DHashTableInit(
|
||||
PLDHashTable2* aTable, const PLDHashTableOps* aOps,
|
||||
uint32_t aEntrySize, uint32_t aLength = PL_DHASH_DEFAULT_INITIAL_LENGTH);
|
||||
|
||||
/*
|
||||
* Free |aTable|'s entry storage (via aTable->mOps->freeTable). Use this
|
||||
* function to destroy a PLDHashTable that is allocated on the stack or in
|
||||
* static memory and was created via PL_DHashTableInit().
|
||||
*/
|
||||
void PL_DHashTableFinish(PLDHashTable* aTable);
|
||||
void PL_DHashTableFinish(PLDHashTable2* aTable);
|
||||
|
||||
/*
|
||||
* To search for a key in |table|, call:
|
||||
*
|
||||
|
|
Загрузка…
Ссылка в новой задаче