mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-28 13:43:45 +03: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
@ -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 New Issue
Block a user