mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Backout changeset aec1ad4171a1 (bug 769504) because of merge conflicts with the rest of the backouts
This commit is contained in:
parent
c8900e25c1
commit
c78cfe9cc2
@ -644,9 +644,9 @@ class OrderedHashSet
|
||||
bool
|
||||
HashableValue::setValue(JSContext *cx, const Value &v)
|
||||
{
|
||||
if (v.isString()) {
|
||||
// Atomize so that hash() and equals() are fast and infallible.
|
||||
JSString *str = js_AtomizeString(cx, v.toString(), DoNotInternAtom);
|
||||
if (v.isString() && v.toString()->isRope()) {
|
||||
// Flatten this rope so that equals() is infallible.
|
||||
JSString *str = v.toString()->ensureLinear(cx);
|
||||
if (!str)
|
||||
return false;
|
||||
value = StringValue(str);
|
||||
@ -676,15 +676,26 @@ HashableValue::hash() const
|
||||
{
|
||||
// HashableValue::setValue normalizes values so that the SameValue relation
|
||||
// on HashableValues is the same as the == relationship on
|
||||
// value.data.asBits.
|
||||
return value.asRawBits();
|
||||
// value.data.asBits, except for strings.
|
||||
if (value.isString()) {
|
||||
JSLinearString &s = value.toString()->asLinear();
|
||||
return HashChars(s.chars(), s.length());
|
||||
}
|
||||
|
||||
// Having dispensed with strings, we can just hash asBits.
|
||||
uint64_t u = value.asRawBits();
|
||||
return HashNumber((u >> 3) ^ (u >> (32 + 3)) ^ (u << (32 - 3)));
|
||||
}
|
||||
|
||||
bool
|
||||
HashableValue::equals(const HashableValue &other) const
|
||||
{
|
||||
// Two HashableValues are equal if they have equal bits.
|
||||
bool b = (value.asRawBits() == other.value.asRawBits());
|
||||
// Two HashableValues are equal if they have equal bits or they're equal strings.
|
||||
bool b = (value.asRawBits() == other.value.asRawBits()) ||
|
||||
(value.isString() &&
|
||||
other.value.isString() &&
|
||||
EqualStrings(&value.toString()->asLinear(),
|
||||
&other.value.toString()->asLinear()));
|
||||
|
||||
#ifdef DEBUG
|
||||
bool same;
|
||||
|
Loading…
Reference in New Issue
Block a user