From d6036462b1d94205b3c9bb3876640c14490f4288 Mon Sep 17 00:00:00 2001 From: Lukas Tenbrink Date: Fri, 3 Oct 2025 19:07:53 +0200 Subject: [PATCH] Remove `hash_map.h` include from `a_hash_map.h`, and remove cross conversion operators. --- core/templates/a_hash_map.h | 41 ++++++++++++++--------------- scene/animation/animation_mixer.cpp | 2 +- 2 files changed, 21 insertions(+), 22 deletions(-) diff --git a/core/templates/a_hash_map.h b/core/templates/a_hash_map.h index ac48c0c4ef2..079cf1b1302 100644 --- a/core/templates/a_hash_map.h +++ b/core/templates/a_hash_map.h @@ -30,9 +30,14 @@ #pragma once -#include "core/string/ustring.h" -#include "core/templates/hash_map.h" +#include "core/os/memory.h" +#include "core/string/print_string.h" +#include "core/templates/hashfuncs.h" +#include "core/templates/pair.h" +#include + +class String; class StringName; class Variant; @@ -182,8 +187,7 @@ private: if (_metadata[meta_idx].hash == EMPTY_HASH) { #ifdef DEV_ENABLED if (unlikely(distance > 12)) { - WARN_PRINT("Excessive collision count (" + - itos(distance) + "), is the right hash function being used?"); + WARN_PRINT("Excessive collision count, is the right hash function being used?"); } #endif _metadata[meta_idx] = metadata; @@ -657,16 +661,20 @@ public: /* Constructors */ - AHashMap(const AHashMap &p_other) { - _init_from(p_other); + AHashMap(AHashMap &&p_other) { + _elements = p_other._elements; + _metadata = p_other._metadata; + _capacity_mask = p_other._capacity_mask; + _size = p_other._size; + + p_other._elements = nullptr; + p_other._metadata = nullptr; + p_other._capacity_mask = 0; + p_other._size = 0; } - AHashMap(const HashMap &p_other) { - reserve(p_other.size()); - for (const KeyValue &E : p_other) { - uint32_t hash = _hash(E.key); - _insert_element(E.key, E.value, hash); - } + AHashMap(const AHashMap &p_other) { + _init_from(p_other); } void operator=(const AHashMap &p_other) { @@ -679,15 +687,6 @@ public: _init_from(p_other); } - void operator=(const HashMap &p_other) { - reset(); - reserve(p_other.size()); - for (const KeyValue &E : p_other) { - uint32_t hash = _hash(E.key); - _insert_element(E.key, E.value, hash); - } - } - AHashMap(uint32_t p_initial_capacity) { // Capacity can't be 0 and must be 2^n - 1. _capacity_mask = MAX(4u, p_initial_capacity); diff --git a/scene/animation/animation_mixer.cpp b/scene/animation/animation_mixer.cpp index 9185ceed872..27fb0f4ccea 100644 --- a/scene/animation/animation_mixer.cpp +++ b/scene/animation/animation_mixer.cpp @@ -2508,7 +2508,7 @@ void AnimatedValuesBackup::set_data(const AHashMap AnimatedValuesBackup::get_data() const { - HashMap ret; + AHashMap ret; for (const KeyValue &E : data) { AnimationMixer::TrackCache *track = get_cache_copy(E.value); ERR_CONTINUE(!track); // Backup shouldn't contain tracks that cannot be copied, this is a mistake.