Bug 1161377 (part 3, attempt 2) - Convert some easy PL_DHashTable{Init,Finish} cases. r=froydnj.

This commit is contained in:
Nicholas Nethercote
2015-05-12 17:33:26 -07:00
parent 35cc1f7af7
commit faab612820
9 changed files with 58 additions and 125 deletions

View File

@@ -489,6 +489,14 @@ protected:
RuleHash::RuleHash(bool aQuirksMode)
: mRuleCount(0),
mIdTable(aQuirksMode ? &RuleHash_IdTable_CIOps.ops
: &RuleHash_IdTable_CSOps.ops,
sizeof(RuleHashTableEntry)),
mClassTable(aQuirksMode ? &RuleHash_ClassTable_CIOps.ops
: &RuleHash_ClassTable_CSOps.ops,
sizeof(RuleHashTableEntry)),
mTagTable(&RuleHash_TagTable_Ops, sizeof(RuleHashTagTableEntry)),
mNameSpaceTable(&RuleHash_NameSpaceTable_Ops, sizeof(RuleHashTableEntry)),
mUniversalRules(0),
mEnumList(nullptr), mEnumListSize(0),
mQuirksMode(aQuirksMode)
@@ -508,20 +516,6 @@ RuleHash::RuleHash(bool aQuirksMode)
#endif
{
MOZ_COUNT_CTOR(RuleHash);
PL_DHashTableInit(&mIdTable, aQuirksMode ? &RuleHash_IdTable_CIOps.ops
: &RuleHash_IdTable_CSOps.ops,
sizeof(RuleHashTableEntry));
PL_DHashTableInit(&mClassTable, aQuirksMode ? &RuleHash_ClassTable_CIOps.ops
: &RuleHash_ClassTable_CSOps.ops,
sizeof(RuleHashTableEntry));
PL_DHashTableInit(&mTagTable, &RuleHash_TagTable_Ops,
sizeof(RuleHashTagTableEntry));
PL_DHashTableInit(&mNameSpaceTable, &RuleHash_NameSpaceTable_Ops,
sizeof(RuleHashTableEntry));
}
RuleHash::~RuleHash()
@@ -563,11 +557,6 @@ RuleHash::~RuleHash()
if (nullptr != mEnumList) {
delete [] mEnumList;
}
// delete arena for strings and small objects
PL_DHashTableFinish(&mIdTable);
PL_DHashTableFinish(&mClassTable);
PL_DHashTableFinish(&mTagTable);
PL_DHashTableFinish(&mNameSpaceTable);
}
void RuleHash::AppendRuleToTable(PLDHashTable* aTable, const void* aKey,
@@ -866,42 +855,31 @@ struct RuleCascadeData {
: mRuleHash(aQuirksMode),
mStateSelectors(),
mSelectorDocumentStates(0),
mClassSelectors(aQuirksMode ? &AtomSelector_CIOps.ops
: &AtomSelector_CSOps,
sizeof(AtomSelectorEntry)),
mIdSelectors(aQuirksMode ? &AtomSelector_CIOps.ops
: &AtomSelector_CSOps,
sizeof(AtomSelectorEntry)),
// mAttributeSelectors is matching on the attribute _name_, not the
// value, and we case-fold names at parse-time, so this is a
// case-sensitive match.
mAttributeSelectors(&AtomSelector_CSOps, sizeof(AtomSelectorEntry)),
mAnonBoxRules(&RuleHash_TagTable_Ops, sizeof(RuleHashTagTableEntry)),
#ifdef MOZ_XUL
mXULTreeRules(&RuleHash_TagTable_Ops, sizeof(RuleHashTagTableEntry)),
#endif
mKeyframesRuleTable(),
mCounterStyleRuleTable(),
mCacheKey(aMedium),
mNext(nullptr),
mQuirksMode(aQuirksMode)
{
// mAttributeSelectors is matching on the attribute _name_, not the value,
// and we case-fold names at parse-time, so this is a case-sensitive match.
PL_DHashTableInit(&mAttributeSelectors, &AtomSelector_CSOps,
sizeof(AtomSelectorEntry));
PL_DHashTableInit(&mAnonBoxRules, &RuleHash_TagTable_Ops,
sizeof(RuleHashTagTableEntry));
PL_DHashTableInit(&mIdSelectors,
aQuirksMode ? &AtomSelector_CIOps.ops :
&AtomSelector_CSOps,
sizeof(AtomSelectorEntry));
PL_DHashTableInit(&mClassSelectors,
aQuirksMode ? &AtomSelector_CIOps.ops :
&AtomSelector_CSOps,
sizeof(AtomSelectorEntry));
memset(mPseudoElementRuleHashes, 0, sizeof(mPseudoElementRuleHashes));
#ifdef MOZ_XUL
PL_DHashTableInit(&mXULTreeRules, &RuleHash_TagTable_Ops,
sizeof(RuleHashTagTableEntry));
#endif
}
~RuleCascadeData()
{
PL_DHashTableFinish(&mAttributeSelectors);
PL_DHashTableFinish(&mAnonBoxRules);
PL_DHashTableFinish(&mIdSelectors);
PL_DHashTableFinish(&mClassSelectors);
#ifdef MOZ_XUL
PL_DHashTableFinish(&mXULTreeRules);
#endif
for (uint32_t i = 0; i < ArrayLength(mPseudoElementRuleHashes); ++i) {
delete mPseudoElementRuleHashes[i];
}
@@ -3320,11 +3298,9 @@ struct CascadeEnumData {
mPageRules(aPageRules),
mCounterStyleRules(aCounterStyleRules),
mCacheKey(aKey),
mRulesByWeight(&gRulesByWeightOps, sizeof(RuleByWeightEntry), 32),
mSheetType(aSheetType)
{
PL_DHashTableInit(&mRulesByWeight, &gRulesByWeightOps,
sizeof(RuleByWeightEntry), 32);
// Initialize our arena
PL_INIT_ARENA_POOL(&mArena, "CascadeEnumDataArena",
NS_CASCADEENUMDATA_ARENA_BLOCK_SIZE);
@@ -3332,8 +3308,6 @@ struct CascadeEnumData {
~CascadeEnumData()
{
if (mRulesByWeight.IsInitialized())
PL_DHashTableFinish(&mRulesByWeight);
PL_FinishArenaPool(&mArena);
}