AK: HashMap::set() didn't save new values for existing keys.

This commit is contained in:
Andreas Kling 2019-03-25 04:23:17 +01:00
parent 1c67788933
commit 17b9fb7bfc
Notes: sideshowbarker 2024-07-19 14:56:59 +09:00

View file

@ -244,8 +244,10 @@ void HashTable<T, TraitsForT>::set(T&& value)
rehash(1);
auto& bucket = lookup(value);
for (auto& e : bucket.chain) {
if (e == value)
if (e == value) {
e = move(value);
return;
}
}
if (size() >= capacity()) {
rehash(size() + 1);
@ -263,8 +265,10 @@ void HashTable<T, TraitsForT>::set(const T& value)
rehash(1);
auto& bucket = lookup(value);
for (auto& e : bucket.chain) {
if (e == value)
if (e == value) {
e = move(value);
return;
}
}
if (size() >= capacity()) {
rehash(size() + 1);