1
0
Fork 0

[Core] Fix `AHashMap` constructors reserving too few elements

This commit is contained in:
A Thousand Ships 2025-03-06 15:28:37 +01:00
parent 134da37497
commit fad8134dca
No known key found for this signature in database
GPG Key ID: 651D4293F3B6484F
1 changed files with 6 additions and 2 deletions

View File

@ -666,7 +666,9 @@ public:
}
AHashMap(const HashMap<TKey, TValue> &p_other) {
reserve(p_other.size());
if (p_other.size() > get_capacity()) {
reserve(p_other.size());
}
for (const KeyValue<TKey, TValue> &E : p_other) {
uint32_t hash = _hash(E.key);
_insert_element(E.key, E.value, hash);
@ -704,7 +706,9 @@ public:
}
AHashMap(std::initializer_list<KeyValue<TKey, TValue>> p_init) {
reserve(p_init.size());
if (p_init.size() > get_capacity()) {
reserve(p_init.size());
}
for (const KeyValue<TKey, TValue> &E : p_init) {
insert(E.key, E.value);
}