3030
3131#pragma once
3232
33- #include " core/string/ustring.h"
34- #include " core/templates/hash_map.h"
33+ #include " core/os/memory.h"
34+ #include " core/string/print_string.h"
35+ #include " core/templates/hashfuncs.h"
36+ #include " core/templates/pair.h"
3537
38+ #include < initializer_list>
39+
40+ class String ;
3641class StringName ;
3742class Variant ;
3843
@@ -182,8 +187,7 @@ class AHashMap {
182187 if (_metadata[meta_idx].hash == EMPTY_HASH) {
183188#ifdef DEV_ENABLED
184189 if (unlikely (distance > 12 )) {
185- WARN_PRINT (" Excessive collision count (" +
186- itos (distance) + " ), is the right hash function being used?" );
190+ WARN_PRINT (" Excessive collision count, is the right hash function being used?" );
187191 }
188192#endif
189193 _metadata[meta_idx] = metadata;
@@ -657,16 +661,20 @@ class AHashMap {
657661
658662 /* Constructors */
659663
660- AHashMap (const AHashMap &p_other) {
661- _init_from (p_other);
664+ AHashMap (AHashMap &&p_other) {
665+ _elements = p_other._elements ;
666+ _metadata = p_other._metadata ;
667+ _capacity_mask = p_other._capacity_mask ;
668+ _size = p_other._size ;
669+
670+ p_other._elements = nullptr ;
671+ p_other._metadata = nullptr ;
672+ p_other._capacity_mask = 0 ;
673+ p_other._size = 0 ;
662674 }
663675
664- AHashMap (const HashMap<TKey, TValue> &p_other) {
665- reserve (p_other.size ());
666- for (const KeyValue<TKey, TValue> &E : p_other) {
667- uint32_t hash = _hash (E.key );
668- _insert_element (E.key , E.value , hash);
669- }
676+ AHashMap (const AHashMap &p_other) {
677+ _init_from (p_other);
670678 }
671679
672680 void operator =(const AHashMap &p_other) {
@@ -679,15 +687,6 @@ class AHashMap {
679687 _init_from (p_other);
680688 }
681689
682- void operator =(const HashMap<TKey, TValue> &p_other) {
683- reset ();
684- reserve (p_other.size ());
685- for (const KeyValue<TKey, TValue> &E : p_other) {
686- uint32_t hash = _hash (E.key );
687- _insert_element (E.key , E.value , hash);
688- }
689- }
690-
691690 AHashMap (uint32_t p_initial_capacity) {
692691 // Capacity can't be 0 and must be 2^n - 1.
693692 _capacity_mask = MAX (4u , p_initial_capacity);
0 commit comments