mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-21 23:20:20 +00:00
AK: HashMap::set() didn't save new values for existing keys.
This commit is contained in:
parent
1c67788933
commit
17b9fb7bfc
Notes:
sideshowbarker
2024-07-19 14:56:59 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/17b9fb7bfc8
1 changed files with 6 additions and 2 deletions
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue