Bug 1239888 - Inline PLDHashTable::{Done,Get}(). r=froydnj.

They're trivial and very hot. This reduces binary size in a 64-bit Linux opt build by 20 KiB and avoiding the calls can only help performance.
This commit is contained in:
Nicholas Nethercote 2016-01-14 21:39:11 -08:00
parent 1ebf19a661
commit b6f69a0d95
2 changed files with 36 additions and 51 deletions

View File

@ -274,33 +274,6 @@ PLDHashTable::Hash2(PLDHashNumber aHash,
// uses the high order bits of mKeyHash, so this least-significant reservation
// should not hurt the hash function's effectiveness much.
/* static */ MOZ_ALWAYS_INLINE bool
PLDHashTable::EntryIsFree(PLDHashEntryHdr* aEntry)
{
return aEntry->mKeyHash == 0;
}
/* static */ MOZ_ALWAYS_INLINE bool
PLDHashTable::EntryIsRemoved(PLDHashEntryHdr* aEntry)
{
return aEntry->mKeyHash == 1;
}
/* static */ MOZ_ALWAYS_INLINE bool
PLDHashTable::EntryIsLive(PLDHashEntryHdr* aEntry)
{
return aEntry->mKeyHash >= 2;
}
/* static */ MOZ_ALWAYS_INLINE void
PLDHashTable::MarkEntryFree(PLDHashEntryHdr* aEntry)
{
aEntry->mKeyHash = 0;
}
/* static */ MOZ_ALWAYS_INLINE void
PLDHashTable::MarkEntryRemoved(PLDHashEntryHdr* aEntry)
{
aEntry->mKeyHash = 1;
}
// Match an entry's mKeyHash against an unstored one computed from a key.
/* static */ bool
PLDHashTable::MatchEntryKeyhash(PLDHashEntryHdr* aEntry, PLDHashNumber aKeyHash)
@ -783,12 +756,6 @@ PLDHashTable::Iterator::~Iterator()
}
}
bool
PLDHashTable::Iterator::Done() const
{
return mNexts == mNextsLimit;
}
MOZ_ALWAYS_INLINE bool
PLDHashTable::Iterator::IsOnNonLiveEntry() const
{
@ -805,16 +772,6 @@ PLDHashTable::Iterator::MoveToNextEntry()
}
}
PLDHashEntryHdr*
PLDHashTable::Iterator::Get() const
{
MOZ_ASSERT(!Done());
PLDHashEntryHdr* entry = reinterpret_cast<PLDHashEntryHdr*>(mCurrent);
MOZ_ASSERT(EntryIsLive(entry));
return entry;
}
void
PLDHashTable::Iterator::Next()
{

View File

@ -450,9 +450,21 @@ public:
Iterator(Iterator&& aOther);
~Iterator();
bool Done() const; // Have we finished?
PLDHashEntryHdr* Get() const; // Get the current entry.
void Next(); // Advance to the next entry.
// Have we finished?
bool Done() const { return mNexts == mNextsLimit; }
// Get the current entry.
PLDHashEntryHdr* Get() const
{
MOZ_ASSERT(!Done());
PLDHashEntryHdr* entry = reinterpret_cast<PLDHashEntryHdr*>(mCurrent);
MOZ_ASSERT(EntryIsLive(entry));
return entry;
}
// Advance to the next entry.
void Next();
// Remove the current entry. Must only be called once per entry, and Get()
// must not be called on that entry afterwards.
@ -498,11 +510,27 @@ private:
static const PLDHashNumber kCollisionFlag = 1;
static bool EntryIsFree(PLDHashEntryHdr* aEntry);
static bool EntryIsRemoved(PLDHashEntryHdr* aEntry);
static bool EntryIsLive(PLDHashEntryHdr* aEntry);
static void MarkEntryFree(PLDHashEntryHdr* aEntry);
static void MarkEntryRemoved(PLDHashEntryHdr* aEntry);
static bool EntryIsFree(PLDHashEntryHdr* aEntry)
{
return aEntry->mKeyHash == 0;
}
static bool EntryIsRemoved(PLDHashEntryHdr* aEntry)
{
return aEntry->mKeyHash == 1;
}
static bool EntryIsLive(PLDHashEntryHdr* aEntry)
{
return aEntry->mKeyHash >= 2;
}
static void MarkEntryFree(PLDHashEntryHdr* aEntry)
{
aEntry->mKeyHash = 0;
}
static void MarkEntryRemoved(PLDHashEntryHdr* aEntry)
{
aEntry->mKeyHash = 1;
}
PLDHashNumber Hash1(PLDHashNumber aHash0);
void Hash2(PLDHashNumber aHash, uint32_t& aHash2Out, uint32_t& aSizeMaskOut);