mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1166586 (part 2) - Convert some easy PL_DHashTable{Init,Finish} cases. r=froydnj.
This patch converts easy cases, i.e. where the PL_DHashTableInit() call occurs in a constructor and the PL_DHashTableFinish() call occurs in a destructor.
This commit is contained in:
parent
ff1ac7eae3
commit
b83a45935c
@ -57,7 +57,7 @@ public:
|
||||
size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf);
|
||||
|
||||
nsCOMPtr<nsIAtom> mName; // property name
|
||||
PLDHashTable mObjectValueMap; // map of object/value pairs
|
||||
PLDHashTable2 mObjectValueMap; // map of object/value pairs
|
||||
NSPropertyDtorFunc mDtorFunc; // property specific value dtor function
|
||||
void* mDtorData; // pointer to pass to dtor
|
||||
bool mTransfer; // whether to transfer in
|
||||
@ -287,21 +287,18 @@ nsPropertyTable::PropertyList::PropertyList(nsIAtom *aName,
|
||||
void *aDtorData,
|
||||
bool aTransfer)
|
||||
: mName(aName),
|
||||
mObjectValueMap(PL_DHashGetStubOps(), sizeof(PropertyListMapEntry)),
|
||||
mDtorFunc(aDtorFunc),
|
||||
mDtorData(aDtorData),
|
||||
mTransfer(aTransfer),
|
||||
mNext(nullptr)
|
||||
{
|
||||
PL_DHashTableInit(&mObjectValueMap, PL_DHashGetStubOps(),
|
||||
sizeof(PropertyListMapEntry));
|
||||
}
|
||||
|
||||
nsPropertyTable::PropertyList::~PropertyList()
|
||||
{
|
||||
PL_DHashTableFinish(&mObjectValueMap);
|
||||
}
|
||||
|
||||
|
||||
static PLDHashOperator
|
||||
DestroyPropertyEnumerator(PLDHashTable *table, PLDHashEntryHdr *hdr,
|
||||
uint32_t number, void *arg)
|
||||
|
@ -450,10 +450,10 @@ protected:
|
||||
|
||||
int32_t mRuleCount;
|
||||
|
||||
PLDHashTable mIdTable;
|
||||
PLDHashTable mClassTable;
|
||||
PLDHashTable mTagTable;
|
||||
PLDHashTable mNameSpaceTable;
|
||||
PLDHashTable2 mIdTable;
|
||||
PLDHashTable2 mClassTable;
|
||||
PLDHashTable2 mTagTable;
|
||||
PLDHashTable2 mNameSpaceTable;
|
||||
RuleValueList mUniversalRules;
|
||||
|
||||
struct EnumData {
|
||||
@ -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];
|
||||
}
|
||||
@ -914,14 +892,14 @@ struct RuleCascadeData {
|
||||
mPseudoElementRuleHashes[nsCSSPseudoElements::ePseudo_PseudoElementCount];
|
||||
nsTArray<nsCSSRuleProcessor::StateSelector> mStateSelectors;
|
||||
EventStates mSelectorDocumentStates;
|
||||
PLDHashTable mClassSelectors;
|
||||
PLDHashTable mIdSelectors;
|
||||
PLDHashTable2 mClassSelectors;
|
||||
PLDHashTable2 mIdSelectors;
|
||||
nsTArray<nsCSSSelector*> mPossiblyNegatedClassSelectors;
|
||||
nsTArray<nsCSSSelector*> mPossiblyNegatedIDSelectors;
|
||||
PLDHashTable mAttributeSelectors;
|
||||
PLDHashTable mAnonBoxRules;
|
||||
PLDHashTable2 mAttributeSelectors;
|
||||
PLDHashTable2 mAnonBoxRules;
|
||||
#ifdef MOZ_XUL
|
||||
PLDHashTable mXULTreeRules;
|
||||
PLDHashTable2 mXULTreeRules;
|
||||
#endif
|
||||
|
||||
nsTArray<nsFontFaceRuleContainer> mFontFaceRules;
|
||||
@ -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);
|
||||
}
|
||||
|
||||
@ -3347,7 +3321,7 @@ struct CascadeEnumData {
|
||||
PLArenaPool mArena;
|
||||
// Hooray, a manual PLDHashTable since nsClassHashtable doesn't
|
||||
// provide a getter that gives me a *reference* to the value.
|
||||
PLDHashTable mRulesByWeight; // of PerWeightDataListItem linked lists
|
||||
PLDHashTable2 mRulesByWeight; // of PerWeightDataListItem linked lists
|
||||
uint8_t mSheetType;
|
||||
};
|
||||
|
||||
|
@ -39,22 +39,15 @@ static const PLDHashTableOps gSetOps = {
|
||||
nsNSSShutDownList *nsNSSShutDownList::singleton = nullptr;
|
||||
|
||||
nsNSSShutDownList::nsNSSShutDownList()
|
||||
:mListLock("nsNSSShutDownList.mListLock")
|
||||
: mListLock("nsNSSShutDownList.mListLock")
|
||||
, mActiveSSLSockets(0)
|
||||
, mObjects(&gSetOps, sizeof(ObjectHashEntry))
|
||||
, mPK11LogoutCancelObjects(&gSetOps, sizeof(ObjectHashEntry))
|
||||
{
|
||||
mActiveSSLSockets = 0;
|
||||
PL_DHashTableInit(&mObjects, &gSetOps, sizeof(ObjectHashEntry));
|
||||
PL_DHashTableInit(&mPK11LogoutCancelObjects, &gSetOps,
|
||||
sizeof(ObjectHashEntry));
|
||||
}
|
||||
|
||||
nsNSSShutDownList::~nsNSSShutDownList()
|
||||
{
|
||||
if (mObjects.IsInitialized()) {
|
||||
PL_DHashTableFinish(&mObjects);
|
||||
}
|
||||
if (mPK11LogoutCancelObjects.IsInitialized()) {
|
||||
PL_DHashTableFinish(&mPK11LogoutCancelObjects);
|
||||
}
|
||||
PR_ASSERT(this == singleton);
|
||||
singleton = nullptr;
|
||||
}
|
||||
|
@ -157,9 +157,9 @@ private:
|
||||
protected:
|
||||
mozilla::Mutex mListLock;
|
||||
static nsNSSShutDownList *singleton;
|
||||
PLDHashTable mObjects;
|
||||
uint32_t mActiveSSLSockets;
|
||||
PLDHashTable mPK11LogoutCancelObjects;
|
||||
PLDHashTable2 mObjects;
|
||||
PLDHashTable2 mPK11LogoutCancelObjects;
|
||||
nsNSSActivityState mActivityState;
|
||||
};
|
||||
|
||||
|
@ -91,12 +91,22 @@ class nsDefaultComparator <nsDocLoader::nsListenerInfo, nsIWebProgressListener*>
|
||||
}
|
||||
};
|
||||
|
||||
/* static */ const PLDHashTableOps nsDocLoader::sRequestInfoHashOps =
|
||||
{
|
||||
PL_DHashVoidPtrKeyStub,
|
||||
PL_DHashMatchEntryStub,
|
||||
PL_DHashMoveEntryStub,
|
||||
nsDocLoader::RequestInfoHashClearEntry,
|
||||
nsDocLoader::RequestInfoHashInitEntry
|
||||
};
|
||||
|
||||
nsDocLoader::nsDocLoader()
|
||||
: mParent(nullptr),
|
||||
mCurrentSelfProgress(0),
|
||||
mMaxSelfProgress(0),
|
||||
mCurrentTotalProgress(0),
|
||||
mMaxTotalProgress(0),
|
||||
mRequestInfoHash(&sRequestInfoHashOps, sizeof(nsRequestInfo)),
|
||||
mCompletedTotalProgress(0),
|
||||
mIsLoadingDocument(false),
|
||||
mIsRestoringDocument(false),
|
||||
@ -107,17 +117,6 @@ nsDocLoader::nsDocLoader()
|
||||
gDocLoaderLog = PR_NewLogModule("DocLoader");
|
||||
}
|
||||
|
||||
static const PLDHashTableOps hash_table_ops =
|
||||
{
|
||||
PL_DHashVoidPtrKeyStub,
|
||||
PL_DHashMatchEntryStub,
|
||||
PL_DHashMoveEntryStub,
|
||||
RequestInfoHashClearEntry,
|
||||
RequestInfoHashInitEntry
|
||||
};
|
||||
|
||||
PL_DHashTableInit(&mRequestInfoHash, &hash_table_ops, sizeof(nsRequestInfo));
|
||||
|
||||
ClearInternalProgress();
|
||||
|
||||
PR_LOG(gDocLoaderLog, PR_LOG_DEBUG,
|
||||
@ -134,10 +133,6 @@ nsDocLoader::SetDocLoaderParent(nsDocLoader *aParent)
|
||||
nsresult
|
||||
nsDocLoader::Init()
|
||||
{
|
||||
if (!mRequestInfoHash.IsInitialized()) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
nsresult rv = NS_NewLoadGroup(getter_AddRefs(mLoadGroup), this);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
@ -166,10 +161,6 @@ nsDocLoader::~nsDocLoader()
|
||||
|
||||
PR_LOG(gDocLoaderLog, PR_LOG_DEBUG,
|
||||
("DocLoader:%p: deleted.\n", this));
|
||||
|
||||
if (mRequestInfoHash.IsInitialized()) {
|
||||
PL_DHashTableFinish(&mRequestInfoHash);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1361,12 +1352,6 @@ RemoveInfoCallback(PLDHashTable *table, PLDHashEntryHdr *hdr, uint32_t number,
|
||||
|
||||
void nsDocLoader::ClearRequestInfoHash(void)
|
||||
{
|
||||
if (!mRequestInfoHash.IsInitialized() || !mRequestInfoHash.EntryCount()) {
|
||||
// No hash, or the hash is empty, nothing to do here then...
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
PL_DHashTableEnumerate(&mRequestInfoHash, RemoveInfoCallback, nullptr);
|
||||
}
|
||||
|
||||
|
@ -276,7 +276,7 @@ protected:
|
||||
int64_t mCurrentTotalProgress;
|
||||
int64_t mMaxTotalProgress;
|
||||
|
||||
PLDHashTable mRequestInfoHash;
|
||||
PLDHashTable2 mRequestInfoHash;
|
||||
int64_t mCompletedTotalProgress;
|
||||
|
||||
mozilla::LinkedList<nsStatusInfo> mStatusInfoList;
|
||||
@ -302,6 +302,8 @@ protected:
|
||||
bool mIsFlushingLayout;
|
||||
|
||||
private:
|
||||
static const PLDHashTableOps sRequestInfoHashOps;
|
||||
|
||||
// A list of kids that are in the middle of their onload calls and will let
|
||||
// us know once they're done. We don't want to fire onload for "normal"
|
||||
// DocLoaderIsEmpty calls (those coming from requests finishing in our
|
||||
|
@ -460,19 +460,14 @@ nsPropertiesParser::ParseBuffer(const char16_t* aBuffer,
|
||||
|
||||
nsPersistentProperties::nsPersistentProperties()
|
||||
: mIn(nullptr)
|
||||
, mTable(&property_HashTableOps, sizeof(PropertyTableEntry), 16)
|
||||
{
|
||||
PL_DHashTableInit(&mTable, &property_HashTableOps,
|
||||
sizeof(PropertyTableEntry), 16);
|
||||
|
||||
PL_INIT_ARENA_POOL(&mArena, "PersistentPropertyArena", 2048);
|
||||
}
|
||||
|
||||
nsPersistentProperties::~nsPersistentProperties()
|
||||
{
|
||||
PL_FinishArenaPool(&mArena);
|
||||
if (mTable.IsInitialized()) {
|
||||
PL_DHashTableFinish(&mTable);
|
||||
}
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -33,7 +33,7 @@ private:
|
||||
protected:
|
||||
nsCOMPtr<nsIUnicharInputStream> mIn;
|
||||
|
||||
PLDHashTable mTable;
|
||||
PLDHashTable2 mTable;
|
||||
PLArenaPool mArena;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user