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.
2 parents a8bab92 + fad8134 commit 4c90863Copy full SHA for 4c90863
core/templates/a_hash_map.h
@@ -665,7 +665,9 @@ class AHashMap {
665
}
666
667
AHashMap(const HashMap<TKey, TValue> &p_other) {
668
- reserve(p_other.size());
+ if (p_other.size() > get_capacity()) {
669
+ reserve(p_other.size());
670
+ }
671
for (const KeyValue<TKey, TValue> &E : p_other) {
672
uint32_t hash = _hash(E.key);
673
_insert_element(E.key, E.value, hash);
@@ -703,7 +705,9 @@ class AHashMap {
703
705
704
706
707
AHashMap(std::initializer_list<KeyValue<TKey, TValue>> p_init) {
- reserve(p_init.size());
708
+ if (p_init.size() > get_capacity()) {
709
+ reserve(p_init.size());
710
711
for (const KeyValue<TKey, TValue> &E : p_init) {
712
insert(E.key, E.value);
713
0 commit comments