We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
AHashMap
1 parent 134da37 commit fad8134Copy full SHA for fad8134
core/templates/a_hash_map.h
@@ -666,7 +666,9 @@ class AHashMap {
666
}
667
668
AHashMap(const HashMap<TKey, TValue> &p_other) {
669
- reserve(p_other.size());
+ if (p_other.size() > get_capacity()) {
670
+ reserve(p_other.size());
671
+ }
672
for (const KeyValue<TKey, TValue> &E : p_other) {
673
uint32_t hash = _hash(E.key);
674
_insert_element(E.key, E.value, hash);
@@ -704,7 +706,9 @@ class AHashMap {
704
706
705
707
708
AHashMap(std::initializer_list<KeyValue<TKey, TValue>> p_init) {
- reserve(p_init.size());
709
+ if (p_init.size() > get_capacity()) {
710
+ reserve(p_init.size());
711
712
for (const KeyValue<TKey, TValue> &E : p_init) {
713
insert(E.key, E.value);
714
0 commit comments