Skip to content

Commit c01c7b8

Browse files
committed
Merge pull request #111221 from Ivorforce/ahashmap-no-hashmap-include
Remove `hash_map.h` include from `a_hash_map.h`, and remove cross conversion operators
2 parents 9fc656d + d603646 commit c01c7b8

File tree

2 files changed

+21
-22
lines changed

2 files changed

+21
-22
lines changed

core/templates/a_hash_map.h

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,14 @@
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;
3641
class StringName;
3742
class 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);

scene/animation/animation_mixer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2508,7 +2508,7 @@ void AnimatedValuesBackup::set_data(const AHashMap<Animation::TypeHash, Animatio
25082508
}
25092509

25102510
AHashMap<Animation::TypeHash, AnimationMixer::TrackCache *, HashHasher> AnimatedValuesBackup::get_data() const {
2511-
HashMap<Animation::TypeHash, AnimationMixer::TrackCache *> ret;
2511+
AHashMap<Animation::TypeHash, AnimationMixer::TrackCache *, HashHasher> ret;
25122512
for (const KeyValue<Animation::TypeHash, AnimationMixer::TrackCache *> &E : data) {
25132513
AnimationMixer::TrackCache *track = get_cache_copy(E.value);
25142514
ERR_CONTINUE(!track); // Backup shouldn't contain tracks that cannot be copied, this is a mistake.

0 commit comments

Comments
 (0)