Bug 1239515 - Simplify HashSet's key-overwriting interface; r=sunfish

This commit is contained in:
Terrence Cole 2016-01-14 09:43:30 -08:00
Родитель 94a91b8195
Коммит 3c0b63c8e8
2 изменённых файлов: 10 добавлений и 13 удалений

Просмотреть файл

@ -498,11 +498,16 @@ class HashSet
return false;
}
// Infallibly rekey one entry with a new key that is equivalent.
void rekeyInPlace(Ptr p, const T& new_value)
{
// Infallibly replace the current key at |p| with an equivalent key.
// Specifically, both HashPolicy::hash and HashPolicy::match must return
// identical results for the new and old key when applied against all
// possible matching values.
void replaceKey(Ptr p, const T& new_value) {
MOZ_ASSERT(p.found());
MOZ_ASSERT(*p != new_value);
MOZ_ASSERT(HashPolicy::hash(*p) == HashPolicy::hash(new_value));
MOZ_ASSERT(HashPolicy::match(*p, new_value));
impl.rekeyInPlace(p, new_value);
const_cast<T&>(*p) = new_value;
}
// HashSet is movable
@ -1755,14 +1760,6 @@ class HashTable : private AllocPolicy
checkOverRemoved();
}
void rekeyInPlace(Ptr p, const Key& k)
{
MOZ_ASSERT(table);
mozilla::ReentrancyGuard g(*this);
MOZ_ASSERT(p.found());
HashPolicy::rekey(const_cast<Key&>(*p), const_cast<Key&>(k));
}
#undef METER
};

Просмотреть файл

@ -108,7 +108,7 @@ ValueNumberer::VisibleValues::add(AddPtr p, MDefinition* def)
void
ValueNumberer::VisibleValues::overwrite(AddPtr p, MDefinition* def)
{
set_.rekeyInPlace(p, def);
set_.replaceKey(p, def);
}
// |def| will be discarded, so remove it from any sets.