Bug 899834 (attempt 2) - Use a better hash function for the atoms table. r=luke.

--HG--
extra : rebase_source : 8de314d19777ec380c8a4462b04563d77879526f
This commit is contained in:
Nicholas Nethercote 2013-07-30 18:01:26 -07:00
parent 8576d5670d
commit 36dcdbd154

View File

@ -53,16 +53,6 @@ struct JsidHasher
extern const char *
AtomToPrintableString(ExclusiveContext *cx, JSAtom *atom, JSAutoByteString *bytes);
/* Compute a hash function from chars/length. */
inline uint32_t
HashChars(const jschar *chars, size_t length)
{
uint32_t h = 0;
for (; length; chars++, length--)
h = JS_ROTATE_LEFT32(h, 4) ^ *chars;
return h;
}
class AtomStateEntry
{
uintptr_t bits;
@ -105,7 +95,7 @@ struct AtomHasher
inline Lookup(const JSAtom *atom);
};
static HashNumber hash(const Lookup &l) { return HashChars(l.chars, l.length); }
static HashNumber hash(const Lookup &l) { return mozilla::HashString(l.chars, l.length); }
static inline bool match(const AtomStateEntry &entry, const Lookup &lookup);
};