Skip to content

Commit d98ab29

Browse files
committed
Bug 1460674 - part 0a - store the hash table entry size in iterators; r=njn
This change is satisfying insofar as it removes a load from every iteration step over the hashtable, but it doesn't seem to affect our collection benchmarks in any way. The change does not make iterators any larger, as there is padding at the end of the iterator structure on both 32- and 64-bit platforms.
1 parent 5428f49 commit d98ab29

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

xpcom/ds/PLDHashTable.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -728,6 +728,7 @@ PLDHashTable::Iterator::Iterator(Iterator&& aOther)
728728
, mNexts(aOther.mNexts)
729729
, mNextsLimit(aOther.mNextsLimit)
730730
, mHaveRemoved(aOther.mHaveRemoved)
731+
, mEntrySize(aOther.mEntrySize)
731732
{
732733
// No need to change |mChecker| here.
733734
aOther.mTable = nullptr;
@@ -736,6 +737,7 @@ PLDHashTable::Iterator::Iterator(Iterator&& aOther)
736737
aOther.mNexts = 0;
737738
aOther.mNextsLimit = 0;
738739
aOther.mHaveRemoved = false;
740+
aOther.mEntrySize = 0;
739741
}
740742

741743
PLDHashTable::Iterator::Iterator(PLDHashTable* aTable)
@@ -745,6 +747,7 @@ PLDHashTable::Iterator::Iterator(PLDHashTable* aTable)
745747
, mNexts(0)
746748
, mNextsLimit(mTable->EntryCount())
747749
, mHaveRemoved(false)
750+
, mEntrySize(aTable->mEntrySize)
748751
{
749752
#ifdef DEBUG
750753
mTable->mChecker.StartReadOp();
@@ -788,7 +791,7 @@ PLDHashTable::Iterator::IsOnNonLiveEntry() const
788791
MOZ_ALWAYS_INLINE void
789792
PLDHashTable::Iterator::MoveToNextEntry()
790793
{
791-
mCurrent += mTable->mEntrySize;
794+
mCurrent += mEntrySize;
792795
if (mCurrent == mLimit) {
793796
mCurrent = mTable->mEntryStore.Get(); // Wrap-around. Possible due to Chaos Mode.
794797
}

xpcom/ds/PLDHashTable.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,7 @@ class PLDHashTable
491491
uint32_t mNextsLimit; // Next() call limit.
492492

493493
bool mHaveRemoved; // Have any elements been removed?
494+
uint8_t mEntrySize; // Size of entries.
494495

495496
bool IsOnNonLiveEntry() const;
496497
void MoveToNextEntry();

0 commit comments

Comments
 (0)