Bug 1477626 - Use `uint32_t` instead of `unsigned` in HashTable.h. r=Waldo
Because it's more precise, and gives us more consistency.
MozReview-Commit-ID: BLYXYSHgZ7v
--- a/js/public/HashTable.h
+++ b/js/public/HashTable.h
@@ -1249,32 +1249,32 @@ class HashTable : private AllocPolicy
} stats;
# define METER(x) x
#else
# define METER(x)
#endif
// The default initial capacity is 32 (enough to hold 16 elements), but it
// can be as low as 4.
- static const unsigned sMinCapacity = 4;
- static const unsigned sMaxInit = JS_BIT(CAP_BITS - 1);
- static const unsigned sMaxCapacity = JS_BIT(CAP_BITS);
- static const unsigned sHashBits = mozilla::tl::BitSize<HashNumber>::value;
+ static const uint32_t sMinCapacity = 4;
+ static const uint32_t sMaxInit = JS_BIT(CAP_BITS - 1);
+ static const uint32_t sMaxCapacity = JS_BIT(CAP_BITS);
+ static const uint32_t sHashBits = mozilla::tl::BitSize<HashNumber>::value;
// Hash-table alpha is conceptually a fraction, but to avoid floating-point
// math we implement it as a ratio of integers.
static const uint8_t sAlphaDenominator = 4;
static const uint8_t sMinAlphaNumerator = 1; // min alpha: 1/4
static const uint8_t sMaxAlphaNumerator = 3; // max alpha: 3/4
static const HashNumber sFreeKey = Entry::sFreeKey;
static const HashNumber sRemovedKey = Entry::sRemovedKey;
static const HashNumber sCollisionBit = Entry::sCollisionBit;
- void setTableSizeLog2(unsigned sizeLog2)
+ void setTableSizeLog2(uint32_t sizeLog2)
{
hashShift = sHashBits - sizeLog2;
}
static bool isLiveHash(HashNumber hash)
{
return Entry::isLiveHash(hash);
}
@@ -1397,17 +1397,17 @@ class HashTable : private AllocPolicy
struct DoubleHash
{
HashNumber h2;
HashNumber sizeMask;
};
DoubleHash hash2(HashNumber curKeyHash) const
{
- unsigned sizeLog2 = sHashBits - hashShift;
+ uint32_t sizeLog2 = sHashBits - hashShift;
DoubleHash dh = {
((curKeyHash << sizeLog2) >> hashShift) | 1,
(HashNumber(1) << sizeLog2) - 1
};
return dh;
}
static HashNumber applyDoubleHash(HashNumber h1, const DoubleHash& dh)
@@ -1443,17 +1443,17 @@ class HashTable : private AllocPolicy
}
// Warning: in order for readonlyThreadsafeLookup() to be safe this
// function must not modify the table in any way when |collisionBit| is 0.
// (The use of the METER() macro to increment stats violates this
// restriction but we will live with that for now because it's enabled so
// rarely.)
MOZ_ALWAYS_INLINE Entry&
- lookup(const Lookup& l, HashNumber keyHash, unsigned collisionBit) const
+ lookup(const Lookup& l, HashNumber keyHash, uint32_t collisionBit) const
{
MOZ_ASSERT(isLiveHash(keyHash));
MOZ_ASSERT(!(keyHash & sCollisionBit));
MOZ_ASSERT(collisionBit == 0 || collisionBit == sCollisionBit);
MOZ_ASSERT(table);
METER(stats.searches++);
// Compute the primary hash address.