Skip to content

Commit

Permalink
Bug 1170416 (part 5) - Remove PLDHashTable::IsInitialized(). r=froydnj.
Browse files Browse the repository at this point in the history
|mOps| is always non-null now, and there's no longer any distinction between
and uninitialized and initialized table. Yay.
  • Loading branch information
nnethercote committed May 21, 2015
1 parent cd0c9de commit 5671c82
Show file tree
Hide file tree
Showing 14 changed files with 13 additions and 116 deletions.
2 changes: 1 addition & 1 deletion dom/base/nsDocument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2030,7 +2030,7 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INTERNAL(nsDocument)
tmp->mAnimationController->Traverse(&cb);
}

if (tmp->mSubDocuments && tmp->mSubDocuments->IsInitialized()) {
if (tmp->mSubDocuments) {
PL_DHashTableEnumerate(tmp->mSubDocuments, SubDocTraverser, &cb);
}

Expand Down
5 changes: 0 additions & 5 deletions dom/base/nsPropertyTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,11 +216,6 @@ nsPropertyTable::SetPropertyInternal(nsPropertyOwner aObject,
} else {
propertyList = new PropertyList(aPropertyName, aPropDtorFunc,
aPropDtorData, aTransfer);
if (!propertyList || !propertyList->mObjectValueMap.IsInitialized()) {
delete propertyList;
return NS_ERROR_OUT_OF_MEMORY;
}

propertyList->mNext = mPropertyList;
mPropertyList = propertyList;
}
Expand Down
8 changes: 1 addition & 7 deletions dom/xul/templates/nsContentSupportMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,13 @@
#include "nsContentSupportMap.h"
#include "nsXULElement.h"

nsresult
void
nsContentSupportMap::Remove(nsIContent* aElement)
{
if (!mMap.IsInitialized())
return NS_ERROR_NOT_INITIALIZED;

nsIContent* child = aElement;
do {
PL_DHashTableRemove(&mMap, child);
child = child->GetNextNode(aElement);
} while(child);

return NS_OK;
}


2 changes: 1 addition & 1 deletion dom/xul/templates/nsContentSupportMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class nsContentSupportMap {
return true;
}

nsresult Remove(nsIContent* aElement);
void Remove(nsIContent* aElement);

void Clear() { mMap.Clear(); }

Expand Down
8 changes: 1 addition & 7 deletions gfx/thebes/gfxFT2FontList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@ class FontNameCache {

void Init()
{
if (!mMap.IsInitialized() || !mCache) {
if (!mCache) {
return;
}
uint32_t size;
Expand Down Expand Up @@ -711,9 +711,6 @@ class FontNameCache {
GetInfoForFile(const nsCString& aFileName, nsCString& aFaceList,
uint32_t *aTimestamp, uint32_t *aFilesize)
{
if (!mMap.IsInitialized()) {
return;
}
FNCMapEntry *entry =
static_cast<FNCMapEntry*>(PL_DHashTableSearch(&mMap,
aFileName.get()));
Expand All @@ -732,9 +729,6 @@ class FontNameCache {
CacheFileInfo(const nsCString& aFileName, const nsCString& aFaceList,
uint32_t aTimestamp, uint32_t aFilesize)
{
if (!mMap.IsInitialized()) {
return;
}
FNCMapEntry* entry = static_cast<FNCMapEntry*>
(PL_DHashTableAdd(&mMap, aFileName.get(), fallible));
if (entry) {
Expand Down
24 changes: 9 additions & 15 deletions layout/base/nsFrameManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,13 +164,11 @@ nsFrameManager::GetPlaceholderFrameFor(const nsIFrame* aFrame)
{
NS_PRECONDITION(aFrame, "null param unexpected");

if (mPlaceholderMap.IsInitialized()) {
PlaceholderMapEntry *entry = static_cast<PlaceholderMapEntry*>
(PL_DHashTableSearch(const_cast<PLDHashTable*>(&mPlaceholderMap),
aFrame));
if (entry) {
return entry->placeholderFrame;
}
PlaceholderMapEntry *entry = static_cast<PlaceholderMapEntry*>
(PL_DHashTableSearch(const_cast<PLDHashTable*>(&mPlaceholderMap),
aFrame));
if (entry) {
return entry->placeholderFrame;
}

return nullptr;
Expand Down Expand Up @@ -201,10 +199,8 @@ nsFrameManager::UnregisterPlaceholderFrame(nsPlaceholderFrame* aPlaceholderFrame
NS_PRECONDITION(nsGkAtoms::placeholderFrame == aPlaceholderFrame->GetType(),
"unexpected frame type");

if (mPlaceholderMap.IsInitialized()) {
PL_DHashTableRemove(&mPlaceholderMap,
aPlaceholderFrame->GetOutOfFlowFrame());
}
PL_DHashTableRemove(&mPlaceholderMap,
aPlaceholderFrame->GetOutOfFlowFrame());
}

static PLDHashOperator
Expand All @@ -219,10 +215,8 @@ UnregisterPlaceholders(PLDHashTable* table, PLDHashEntryHdr* hdr,
void
nsFrameManager::ClearPlaceholderFrameMap()
{
if (mPlaceholderMap.IsInitialized()) {
PL_DHashTableEnumerate(&mPlaceholderMap, UnregisterPlaceholders, nullptr);
mPlaceholderMap.Clear();
}
PL_DHashTableEnumerate(&mPlaceholderMap, UnregisterPlaceholders, nullptr);
mPlaceholderMap.Clear();
}

//----------------------------------------------------------------------
Expand Down
3 changes: 0 additions & 3 deletions layout/style/nsCSSRuleProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3521,9 +3521,6 @@ nsCSSRuleProcessor::RefreshRuleCascade(nsPresContext* aPresContext)
newCascade->mCounterStyleRules,
newCascade->mCacheKey,
mSheetType);
if (!data.mRulesByWeight.IsInitialized())
return; /* out of memory */

for (uint32_t i = 0; i < mSheets.Length(); ++i) {
if (!CascadeSheet(mSheets.ElementAt(i), &data))
return; /* out of memory */
Expand Down
3 changes: 0 additions & 3 deletions modules/libpref/nsPrefBranch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -555,9 +555,6 @@ NS_IMETHODIMP nsPrefBranch::GetChildList(const char *aStartingAt, uint32_t *aCou
*aChildArray = nullptr;
*aCount = 0;

if (!gHashTable->IsInitialized())
return NS_ERROR_NOT_INITIALIZED;

// this will contain a list of all the pref name strings
// allocate on the stack for speed

Expand Down
3 changes: 0 additions & 3 deletions xpcom/ds/nsStaticNameTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ int32_t
nsStaticCaseInsensitiveNameTable::Lookup(const nsACString& aName)
{
NS_ASSERTION(mNameArray, "not inited");
NS_ASSERTION(mNameTable.IsInitialized(), "not inited");

const nsAFlatCString& str = PromiseFlatCString(aName);

Expand All @@ -181,7 +180,6 @@ int32_t
nsStaticCaseInsensitiveNameTable::Lookup(const nsAString& aName)
{
NS_ASSERTION(mNameArray, "not inited");
NS_ASSERTION(mNameTable.IsInitialized(), "not inited");

const nsAFlatString& str = PromiseFlatString(aName);

Expand All @@ -196,7 +194,6 @@ const nsAFlatCString&
nsStaticCaseInsensitiveNameTable::GetStringValue(int32_t aIndex)
{
NS_ASSERTION(mNameArray, "not inited");
NS_ASSERTION(mNameTable.IsInitialized(), "not inited");

if ((NOT_FOUND < aIndex) && ((uint32_t)aIndex < mNameTable.EntryCount())) {
return mNameArray[aIndex];
Expand Down
6 changes: 0 additions & 6 deletions xpcom/glue/nsBaseHashtable.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,6 @@ class nsBaseHashtable
*/
uint32_t EnumerateRead(EnumReadFunction aEnumFunc, void* aUserArg) const
{
NS_ASSERTION(this->mTable.IsInitialized(),
"nsBaseHashtable was not initialized properly.");

s_EnumReadArgs enumData = { aEnumFunc, aUserArg };
return PL_DHashTableEnumerate(const_cast<PLDHashTable*>(&this->mTable),
s_EnumReadStub,
Expand Down Expand Up @@ -199,9 +196,6 @@ class nsBaseHashtable
*/
uint32_t Enumerate(EnumFunction aEnumFunc, void* aUserArg)
{
NS_ASSERTION(this->mTable.IsInitialized(),
"nsBaseHashtable was not initialized properly.");

s_EnumArgs enumData = { aEnumFunc, aUserArg };
return PL_DHashTableEnumerate(&this->mTable,
s_EnumStub,
Expand Down
21 changes: 0 additions & 21 deletions xpcom/glue/nsTHashtable.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,6 @@ class nsTHashtable
*/
EntryType* GetEntry(KeyType aKey) const
{
NS_ASSERTION(mTable.IsInitialized(),
"nsTHashtable was not initialized properly.");

return static_cast<EntryType*>(
PL_DHashTableSearch(const_cast<PLDHashTable*>(&mTable),
EntryType::KeyToPointer(aKey)));
Expand All @@ -153,19 +150,13 @@ class nsTHashtable
*/
EntryType* PutEntry(KeyType aKey)
{
NS_ASSERTION(mTable.IsInitialized(),
"nsTHashtable was not initialized properly.");

return static_cast<EntryType*> // infallible add
(PL_DHashTableAdd(&mTable, EntryType::KeyToPointer(aKey)));
}

MOZ_WARN_UNUSED_RESULT
EntryType* PutEntry(KeyType aKey, const fallible_t&)
{
NS_ASSERTION(mTable.IsInitialized(),
"nsTHashtable was not initialized properly.");

return static_cast<EntryType*>
(PL_DHashTableAdd(&mTable, EntryType::KeyToPointer(aKey),
mozilla::fallible));
Expand All @@ -177,9 +168,6 @@ class nsTHashtable
*/
void RemoveEntry(KeyType aKey)
{
NS_ASSERTION(mTable.IsInitialized(),
"nsTHashtable was not initialized properly.");

PL_DHashTableRemove(&mTable,
EntryType::KeyToPointer(aKey));
}
Expand Down Expand Up @@ -218,9 +206,6 @@ class nsTHashtable
*/
uint32_t EnumerateEntries(Enumerator aEnumFunc, void* aUserArg)
{
NS_ASSERTION(mTable.IsInitialized(),
"nsTHashtable was not initialized properly.");

s_EnumArgs args = { aEnumFunc, aUserArg };
return PL_DHashTableEnumerate(&mTable, s_EnumStub, &args);
}
Expand All @@ -230,9 +215,6 @@ class nsTHashtable
*/
void Clear()
{
NS_ASSERTION(mTable.IsInitialized(),
"nsTHashtable was not initialized properly.");

PL_DHashTableEnumerate(&mTable, PL_DHashStubEnumRemove, nullptr);
}

Expand Down Expand Up @@ -320,9 +302,6 @@ class nsTHashtable
*/
void MarkImmutable()
{
NS_ASSERTION(mTable.IsInitialized(),
"nsTHashtable was not initialized properly.");

PL_DHashMarkTableImmutable(&mTable);
}
#endif
Expand Down
27 changes: 0 additions & 27 deletions xpcom/glue/pldhash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -350,8 +350,6 @@ PLDHashTable::~PLDHashTable()
void
PLDHashTable::ClearAndPrepareForLength(uint32_t aLength)
{
MOZ_ASSERT(IsInitialized());

// Get these values before the call to Finish() clobbers them.
const PLDHashTableOps* ops = mOps;
uint32_t entrySize = mEntrySize;
Expand Down Expand Up @@ -567,8 +565,6 @@ PLDHashTable::ComputeKeyHash(const void* aKey)
MOZ_ALWAYS_INLINE PLDHashEntryHdr*
PLDHashTable::Search(const void* aKey)
{
MOZ_ASSERT(IsInitialized());

INCREMENT_RECURSION_LEVEL(this);

METER(mStats.mSearches++);
Expand All @@ -585,8 +581,6 @@ PLDHashTable::Search(const void* aKey)
MOZ_ALWAYS_INLINE PLDHashEntryHdr*
PLDHashTable::Add(const void* aKey, const mozilla::fallible_t&)
{
MOZ_ASSERT(IsInitialized());

PLDHashNumber keyHash;
PLDHashEntryHdr* entry;
uint32_t capacity;
Expand Down Expand Up @@ -692,8 +686,6 @@ PLDHashTable::Add(const void* aKey)
MOZ_ALWAYS_INLINE void
PLDHashTable::Remove(const void* aKey)
{
MOZ_ASSERT(IsInitialized());

MOZ_ASSERT(mRecursionLevel == 0);
INCREMENT_RECURSION_LEVEL(this);

Expand Down Expand Up @@ -748,7 +740,6 @@ PL_DHashTableRemove(PLDHashTable* aTable, const void* aKey)
MOZ_ALWAYS_INLINE void
PLDHashTable::RawRemove(PLDHashEntryHdr* aEntry)
{
MOZ_ASSERT(IsInitialized());
MOZ_ASSERT(mEntryStore);

MOZ_ASSERT(mRecursionLevel != IMMUTABLE_RECURSION_LEVEL);
Expand Down Expand Up @@ -777,8 +768,6 @@ PL_DHashTableRawRemove(PLDHashTable* aTable, PLDHashEntryHdr* aEntry)
MOZ_ALWAYS_INLINE uint32_t
PLDHashTable::Enumerate(PLDHashEnumerator aEtor, void* aArg)
{
MOZ_ASSERT(IsInitialized());

if (!mEntryStore) {
return 0;
}
Expand Down Expand Up @@ -883,8 +872,6 @@ PLDHashTable::SizeOfExcludingThis(
PLDHashSizeOfEntryExcludingThisFun aSizeOfEntryExcludingThis,
MallocSizeOf aMallocSizeOf, void* aArg /* = nullptr */) const
{
MOZ_ASSERT(IsInitialized());

if (!mEntryStore) {
return 0;
}
Expand All @@ -907,8 +894,6 @@ PLDHashTable::SizeOfIncludingThis(
PLDHashSizeOfEntryExcludingThisFun aSizeOfEntryExcludingThis,
MallocSizeOf aMallocSizeOf, void* aArg /* = nullptr */) const
{
MOZ_ASSERT(IsInitialized());

return aMallocSizeOf(this) +
SizeOfExcludingThis(aSizeOfEntryExcludingThis, aMallocSizeOf, aArg);
}
Expand Down Expand Up @@ -938,8 +923,6 @@ PLDHashTable::Iterator::Iterator(const PLDHashTable* aTable)
mEntryAddr(mTable->mEntryStore),
mEntryOffset(0)
{
MOZ_ASSERT(mTable->IsInitialized());

// Make sure that modifications can't simultaneously happen while the iterator
// is active.
INCREMENT_RECURSION_LEVEL(mTable);
Expand Down Expand Up @@ -968,25 +951,19 @@ PLDHashTable::Iterator::Iterator(const Iterator& aIterator)
mEntryAddr(aIterator.mEntryAddr),
mEntryOffset(aIterator.mEntryOffset)
{
MOZ_ASSERT(mTable->IsInitialized());

// We need the copy constructor only so that we can keep the recursion level
// consistent.
INCREMENT_RECURSION_LEVEL(mTable);
}

PLDHashTable::Iterator::~Iterator()
{
MOZ_ASSERT(mTable->IsInitialized());

DECREMENT_RECURSION_LEVEL(mTable);
}

bool
PLDHashTable::Iterator::HasMoreEntries() const
{
MOZ_ASSERT(mTable->IsInitialized());

// Check the number of live entries seen, not the total number of entries
// seen. To see why, consider what happens if the last entry is not live: we
// would have to iterate after returning an entry to see if more live entries
Expand Down Expand Up @@ -1039,8 +1016,6 @@ PLDHashTable::Iterator::NextEntry()
MOZ_ALWAYS_INLINE void
PLDHashTable::MarkImmutable()
{
MOZ_ASSERT(IsInitialized());

mRecursionLevel = IMMUTABLE_RECURSION_LEVEL;
}

Expand All @@ -1057,8 +1032,6 @@ PL_DHashMarkTableImmutable(PLDHashTable* aTable)
void
PLDHashTable::DumpMeter(PLDHashEnumerator aDump, FILE* aFp)
{
MOZ_ASSERT(IsInitialized());

PLDHashNumber hash1, hash2, maxChainHash1, maxChainHash2;
double sqsum, mean, variance, sigma;
PLDHashEntryHdr* entry;
Expand Down
2 changes: 0 additions & 2 deletions xpcom/glue/pldhash.h
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,6 @@ class PLDHashTable

~PLDHashTable();

bool IsInitialized() const { return !!mOps; }

// This should be used rarely.
const PLDHashTableOps* const Ops() { return mOps; }

Expand Down
Loading

0 comments on commit 5671c82

Please sign in to comment.