зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1129786 (part 1) - Instantiate RuleHash::m*Table eagerly. r=bz.
Now that empty PLDHashTables don't allocate any entry storage, we can undo the lazification of RuleHash::m*Table from bug 700914. --HG-- extra : rebase_source : 167d2519f59ddf7dab182601f9a581c872fd7998
This commit is contained in:
Родитель
f1a5b9e646
Коммит
521cb022b6
|
@ -449,7 +449,7 @@ protected:
|
|||
void AppendUniversalRule(const RuleSelectorPair& aRuleInfo);
|
||||
|
||||
int32_t mRuleCount;
|
||||
// The hashtables are lazily initialized.
|
||||
|
||||
PLDHashTable mIdTable;
|
||||
PLDHashTable mClassTable;
|
||||
PLDHashTable mTagTable;
|
||||
|
@ -508,6 +508,20 @@ 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()
|
||||
|
@ -550,18 +564,10 @@ RuleHash::~RuleHash()
|
|||
delete [] mEnumList;
|
||||
}
|
||||
// delete arena for strings and small objects
|
||||
if (mIdTable.IsInitialized()) {
|
||||
PL_DHashTableFinish(&mIdTable);
|
||||
}
|
||||
if (mClassTable.IsInitialized()) {
|
||||
PL_DHashTableFinish(&mClassTable);
|
||||
}
|
||||
if (mTagTable.IsInitialized()) {
|
||||
PL_DHashTableFinish(&mTagTable);
|
||||
}
|
||||
if (mNameSpaceTable.IsInitialized()) {
|
||||
PL_DHashTableFinish(&mNameSpaceTable);
|
||||
}
|
||||
PL_DHashTableFinish(&mIdTable);
|
||||
PL_DHashTableFinish(&mClassTable);
|
||||
PL_DHashTableFinish(&mTagTable);
|
||||
PL_DHashTableFinish(&mNameSpaceTable);
|
||||
}
|
||||
|
||||
void RuleHash::AppendRuleToTable(PLDHashTable* aTable, const void* aKey,
|
||||
|
@ -600,31 +606,15 @@ void RuleHash::AppendRule(const RuleSelectorPair& aRuleInfo)
|
|||
selector = selector->mNext;
|
||||
}
|
||||
if (nullptr != selector->mIDList) {
|
||||
if (!mIdTable.IsInitialized()) {
|
||||
PL_DHashTableInit(&mIdTable,
|
||||
mQuirksMode ? &RuleHash_IdTable_CIOps.ops
|
||||
: &RuleHash_IdTable_CSOps.ops,
|
||||
sizeof(RuleHashTableEntry));
|
||||
}
|
||||
AppendRuleToTable(&mIdTable, selector->mIDList->mAtom, aRuleInfo);
|
||||
RULE_HASH_STAT_INCREMENT(mIdSelectors);
|
||||
}
|
||||
else if (nullptr != selector->mClassList) {
|
||||
if (!mClassTable.IsInitialized()) {
|
||||
PL_DHashTableInit(&mClassTable,
|
||||
mQuirksMode ? &RuleHash_ClassTable_CIOps.ops
|
||||
: &RuleHash_ClassTable_CSOps.ops,
|
||||
sizeof(RuleHashTableEntry));
|
||||
}
|
||||
AppendRuleToTable(&mClassTable, selector->mClassList->mAtom, aRuleInfo);
|
||||
RULE_HASH_STAT_INCREMENT(mClassSelectors);
|
||||
}
|
||||
else if (selector->mLowercaseTag) {
|
||||
RuleValue ruleValue(aRuleInfo, mRuleCount++, mQuirksMode);
|
||||
if (!mTagTable.IsInitialized()) {
|
||||
PL_DHashTableInit(&mTagTable, &RuleHash_TagTable_Ops,
|
||||
sizeof(RuleHashTagTableEntry));
|
||||
}
|
||||
AppendRuleToTagTable(&mTagTable, selector->mLowercaseTag, ruleValue);
|
||||
RULE_HASH_STAT_INCREMENT(mTagSelectors);
|
||||
if (selector->mCasedTag &&
|
||||
|
@ -634,10 +624,6 @@ void RuleHash::AppendRule(const RuleSelectorPair& aRuleInfo)
|
|||
}
|
||||
}
|
||||
else if (kNameSpaceID_Unknown != selector->mNameSpace) {
|
||||
if (!mNameSpaceTable.IsInitialized()) {
|
||||
PL_DHashTableInit(&mNameSpaceTable, &RuleHash_NameSpaceTable_Ops,
|
||||
sizeof(RuleHashTableEntry));
|
||||
}
|
||||
AppendRuleToTable(&mNameSpaceTable,
|
||||
NS_INT32_TO_PTR(selector->mNameSpace), aRuleInfo);
|
||||
RULE_HASH_STAT_INCREMENT(mNameSpaceSelectors);
|
||||
|
@ -694,7 +680,7 @@ void RuleHash::EnumerateAllRules(Element* aElement, ElementDependentRuleProcesso
|
|||
RULE_HASH_STAT_INCREMENT_LIST_COUNT(mUniversalRules, mElementUniversalCalls);
|
||||
}
|
||||
// universal rules within the namespace
|
||||
if (kNameSpaceID_Unknown != nameSpace && mNameSpaceTable.IsInitialized()) {
|
||||
if (kNameSpaceID_Unknown != nameSpace && mNameSpaceTable.EntryCount() > 0) {
|
||||
RuleHashTableEntry *entry = static_cast<RuleHashTableEntry*>
|
||||
(PL_DHashTableSearch(&mNameSpaceTable, NS_INT32_TO_PTR(nameSpace)));
|
||||
if (entry) {
|
||||
|
@ -702,7 +688,7 @@ void RuleHash::EnumerateAllRules(Element* aElement, ElementDependentRuleProcesso
|
|||
RULE_HASH_STAT_INCREMENT_LIST_COUNT(entry->mRules, mElementNameSpaceCalls);
|
||||
}
|
||||
}
|
||||
if (mTagTable.IsInitialized()) {
|
||||
if (mTagTable.EntryCount() > 0) {
|
||||
RuleHashTableEntry *entry = static_cast<RuleHashTableEntry*>
|
||||
(PL_DHashTableSearch(&mTagTable, tag));
|
||||
if (entry) {
|
||||
|
@ -710,7 +696,7 @@ void RuleHash::EnumerateAllRules(Element* aElement, ElementDependentRuleProcesso
|
|||
RULE_HASH_STAT_INCREMENT_LIST_COUNT(entry->mRules, mElementTagCalls);
|
||||
}
|
||||
}
|
||||
if (id && mIdTable.IsInitialized()) {
|
||||
if (id && mIdTable.EntryCount() > 0) {
|
||||
RuleHashTableEntry *entry = static_cast<RuleHashTableEntry*>
|
||||
(PL_DHashTableSearch(&mIdTable, id));
|
||||
if (entry) {
|
||||
|
@ -718,7 +704,7 @@ void RuleHash::EnumerateAllRules(Element* aElement, ElementDependentRuleProcesso
|
|||
RULE_HASH_STAT_INCREMENT_LIST_COUNT(entry->mRules, mElementIdCalls);
|
||||
}
|
||||
}
|
||||
if (mClassTable.IsInitialized()) {
|
||||
if (mClassTable.EntryCount() > 0) {
|
||||
for (int32_t index = 0; index < classCount; ++index) {
|
||||
RuleHashTableEntry *entry = static_cast<RuleHashTableEntry*>
|
||||
(PL_DHashTableSearch(&mClassTable, classList->AtomAt(index)));
|
||||
|
@ -781,29 +767,21 @@ RuleHash::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const
|
|||
{
|
||||
size_t n = 0;
|
||||
|
||||
if (mIdTable.IsInitialized()) {
|
||||
n += PL_DHashTableSizeOfExcludingThis(&mIdTable,
|
||||
SizeOfRuleHashTableEntry,
|
||||
aMallocSizeOf);
|
||||
}
|
||||
n += PL_DHashTableSizeOfExcludingThis(&mIdTable,
|
||||
SizeOfRuleHashTableEntry,
|
||||
aMallocSizeOf);
|
||||
|
||||
if (mClassTable.IsInitialized()) {
|
||||
n += PL_DHashTableSizeOfExcludingThis(&mClassTable,
|
||||
SizeOfRuleHashTableEntry,
|
||||
aMallocSizeOf);
|
||||
}
|
||||
n += PL_DHashTableSizeOfExcludingThis(&mClassTable,
|
||||
SizeOfRuleHashTableEntry,
|
||||
aMallocSizeOf);
|
||||
|
||||
if (mTagTable.IsInitialized()) {
|
||||
n += PL_DHashTableSizeOfExcludingThis(&mTagTable,
|
||||
SizeOfRuleHashTableEntry,
|
||||
aMallocSizeOf);
|
||||
}
|
||||
n += PL_DHashTableSizeOfExcludingThis(&mTagTable,
|
||||
SizeOfRuleHashTableEntry,
|
||||
aMallocSizeOf);
|
||||
|
||||
if (mNameSpaceTable.IsInitialized()) {
|
||||
n += PL_DHashTableSizeOfExcludingThis(&mNameSpaceTable,
|
||||
SizeOfRuleHashTableEntry,
|
||||
aMallocSizeOf);
|
||||
}
|
||||
n += PL_DHashTableSizeOfExcludingThis(&mNameSpaceTable,
|
||||
SizeOfRuleHashTableEntry,
|
||||
aMallocSizeOf);
|
||||
|
||||
n += mUniversalRules.SizeOfExcludingThis(aMallocSizeOf);
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче