Change copy constructors of HashMap and AHashMap from implicit to explicit.

This commit is contained in:
Lukas Tenbrink 2026-01-18 14:18:30 +01:00
parent 741fb8a306
commit 1825e89787
30 changed files with 34 additions and 35 deletions

View file

@ -1640,7 +1640,7 @@ void ProjectSettings::_bind_methods() {
void ProjectSettings::_add_builtin_input_map() {
if (InputMap::get_singleton()) {
HashMap<String, List<Ref<InputEvent>>> builtins = InputMap::get_singleton()->get_builtins();
HashMap<String, List<Ref<InputEvent>>> builtins(InputMap::get_singleton()->get_builtins());
for (KeyValue<String, List<Ref<InputEvent>>> &E : builtins) {
Array events;

View file

@ -900,7 +900,7 @@ const HashMap<String, List<Ref<InputEvent>>> &InputMap::get_builtins_with_featur
}
void InputMap::load_default() {
HashMap<String, List<Ref<InputEvent>>> builtins = get_builtins_with_feature_overrides_applied();
HashMap<String, List<Ref<InputEvent>>> builtins(get_builtins_with_feature_overrides_applied());
for (const KeyValue<String, List<Ref<InputEvent>>> &E : builtins) {
String name = E.key;

View file

@ -673,7 +673,7 @@ public:
p_other._size = 0;
}
AHashMap(const AHashMap &p_other) {
explicit AHashMap(const AHashMap &p_other) {
_init_from(p_other);
}

View file

@ -582,7 +582,7 @@ public:
/* Constructors */
HashMap(const HashMap &p_other) {
explicit HashMap(const HashMap &p_other) {
reserve(hash_table_size_primes[p_other._capacity_idx]);
if (p_other._size == 0) {

View file

@ -619,7 +619,7 @@ bool ShaderGLES3::_load_from_cache(Version *p_version) {
variant.insert(specialization_key, specialization);
}
variants.push_back(variant);
variants.push_back(std::move(variant));
}
p_version->variants = variants;
@ -705,8 +705,7 @@ void ShaderGLES3::_initialize_version(Version *p_version) {
}
p_version->variants.reserve(variant_count);
for (int i = 0; i < variant_count; i++) {
AHashMap<uint64_t, Version::Specialization> variant;
p_version->variants.push_back(variant);
p_version->variants.push_back(AHashMap<uint64_t, Version::Specialization>());
Version::Specialization spec;
_compile_specialization(spec, i, p_version, specialization_default_mask);
p_version->variants[i].insert(specialization_default_mask, spec);

View file

@ -1656,7 +1656,7 @@ void FileSystemDock::_update_dependencies_after_move(const HashMap<String, Strin
void FileSystemDock::_update_project_settings_after_move(const HashMap<String, String> &p_renames, const HashMap<String, String> &p_folders_renames) {
// Find all project settings of type FILE and replace them if needed.
const HashMap<StringName, PropertyInfo> prop_info = ProjectSettings::get_singleton()->get_custom_property_info();
const HashMap<StringName, PropertyInfo> prop_info(ProjectSettings::get_singleton()->get_custom_property_info());
for (const KeyValue<StringName, PropertyInfo> &E : prop_info) {
if (E.value.hint == PROPERTY_HINT_FILE || E.value.hint == PROPERTY_HINT_FILE_PATH) {
String old_path = GLOBAL_GET(E.key);

View file

@ -2785,7 +2785,7 @@ Error EditorFileSystem::_reimport_file(const String &p_file, const HashMap<Strin
//try to obtain existing params
HashMap<StringName, Variant> params = p_custom_options;
HashMap<StringName, Variant> params(p_custom_options);
String importer_name; //empty by default though
if (!p_custom_importer.is_empty()) {

View file

@ -1022,7 +1022,7 @@ void SceneImportSettingsDialog::_inspector_property_edited(const String &p_name)
if (!animation_map.has(selected_id)) {
return;
}
HashMap<StringName, Variant> settings = animation_map[selected_id].settings;
HashMap<StringName, Variant> settings(animation_map[selected_id].settings);
if (settings.has(p_name)) {
animation_loop_mode = static_cast<Animation::LoopMode>((int)settings[p_name]);
} else {
@ -1106,7 +1106,7 @@ void SceneImportSettingsDialog::_reset_animation(const String &p_animation_name)
animation_pingpong = false;
if (animation_map.has(p_animation_name)) {
HashMap<StringName, Variant> settings = animation_map[p_animation_name].settings;
HashMap<StringName, Variant> settings(animation_map[p_animation_name].settings);
if (settings.has("settings/loop_mode")) {
animation_loop_mode = static_cast<Animation::LoopMode>((int)settings["settings/loop_mode"]);
}

View file

@ -3771,7 +3771,7 @@ static EditorProperty *get_input_action_editor(const String &p_hint_text, bool i
ProjectSettings::get_singleton()->get_property_list(&pinfo);
Vector<String> hints = p_hint_text.remove_char(' ').split(",", false);
HashMap<String, List<Ref<InputEvent>>> builtins = InputMap::get_singleton()->get_builtins();
HashMap<String, List<Ref<InputEvent>>> builtins(InputMap::get_singleton()->get_builtins());
bool show_builtin = hints.has("show_builtin");
for (const PropertyInfo &pi : pinfo) {

View file

@ -189,7 +189,7 @@ void GroupSettingsEditor::_group_name_text_changed(const String &p_name) {
void GroupSettingsEditor::_modify_references(const StringName &p_name, const StringName &p_new_name, bool p_is_rename) {
HashSet<String> scenes;
HashMap<StringName, HashSet<StringName>> scene_groups_cache = ProjectSettings::get_singleton()->get_scene_groups_cache();
HashMap<StringName, HashSet<StringName>> scene_groups_cache(ProjectSettings::get_singleton()->get_scene_groups_cache());
for (const KeyValue<StringName, HashSet<StringName>> &E : scene_groups_cache) {
if (E.value.has(p_name)) {
scenes.insert(E.key);

View file

@ -141,7 +141,7 @@ void EditorStandardSyntaxHighlighter::_update_cache() {
}
/* Autoloads. */
HashMap<StringName, ProjectSettings::AutoloadInfo> autoloads = ProjectSettings::get_singleton()->get_autoload_list();
HashMap<StringName, ProjectSettings::AutoloadInfo> autoloads(ProjectSettings::get_singleton()->get_autoload_list());
for (const KeyValue<StringName, ProjectSettings::AutoloadInfo> &E : autoloads) {
const ProjectSettings::AutoloadInfo &info = E.value;
if (info.is_singleton) {

View file

@ -462,7 +462,7 @@ LocalVector<EditorBuildProfile::BuildOption> EditorBuildProfile::get_build_optio
HashMap<String, LocalVector<Variant>> EditorBuildProfile::get_build_option_settings(BuildOption p_build_option) {
ERR_FAIL_INDEX_V(p_build_option, BUILD_OPTION_MAX, (HashMap<String, LocalVector<Variant>>()));
return build_option_settings.has(p_build_option) ? build_option_settings[p_build_option] : HashMap<String, LocalVector<Variant>>();
return build_option_settings.has(p_build_option) ? HashMap<String, LocalVector<Variant>>(build_option_settings[p_build_option]) : HashMap<String, LocalVector<Variant>>();
}
LocalVector<String> EditorBuildProfile::get_build_option_classes(BuildOption p_build_option) {

View file

@ -1637,7 +1637,7 @@ Vector<String> EditorSettings::get_favorites() const {
}
HashMap<String, PackedStringArray> EditorSettings::get_favorite_properties() const {
return favorite_properties;
return HashMap<String, PackedStringArray>(favorite_properties);
}
void EditorSettings::set_recent_dirs(const Vector<String> &p_recent_dirs, bool p_update_file_dialog) {

View file

@ -4364,7 +4364,7 @@ int Main::start() {
if (!game_path.is_empty() || !script.is_empty()) {
//autoload
OS::get_singleton()->benchmark_begin_measure("Startup", "Load Autoloads");
HashMap<StringName, ProjectSettings::AutoloadInfo> autoloads = ProjectSettings::get_singleton()->get_autoload_list();
HashMap<StringName, ProjectSettings::AutoloadInfo> autoloads(ProjectSettings::get_singleton()->get_autoload_list());
//first pass, add the constants so they exist before any script is loaded
for (const KeyValue<StringName, ProjectSettings::AutoloadInfo> &E : autoloads) {

View file

@ -419,7 +419,7 @@ GDScriptCodeGenerator::Address GDScriptCompiler::_parse_expression(CodeGen &code
if (GDScriptLanguage::get_singleton()->get_global_map().has(identifier)) {
// If it's an autoload singleton, we postpone to load it at runtime.
// This is so one autoload doesn't try to load another before it's compiled.
HashMap<StringName, ProjectSettings::AutoloadInfo> autoloads = ProjectSettings::get_singleton()->get_autoload_list();
HashMap<StringName, ProjectSettings::AutoloadInfo> autoloads(ProjectSettings::get_singleton()->get_autoload_list());
if (autoloads.has(identifier) && autoloads[identifier].is_singleton) {
GDScriptCodeGenerator::Address global = codegen.add_temporary(_gdtype_from_datatype(in->get_datatype(), codegen.script));
int idx = GDScriptLanguage::get_singleton()->get_global_map()[identifier];

View file

@ -129,7 +129,7 @@ class GDScriptCompiler {
}
void start_block() {
HashMap<StringName, GDScriptCodeGenerator::Address> old_locals = locals;
HashMap<StringName, GDScriptCodeGenerator::Address> old_locals(locals);
locals_stack.push_back(old_locals);
generator->start_block();
}

View file

@ -1123,7 +1123,7 @@ static void _list_available_types(bool p_inherit_only, GDScriptParser::Completio
}
// Autoload singletons
HashMap<StringName, ProjectSettings::AutoloadInfo> autoloads = ProjectSettings::get_singleton()->get_autoload_list();
HashMap<StringName, ProjectSettings::AutoloadInfo> autoloads(ProjectSettings::get_singleton()->get_autoload_list());
for (const KeyValue<StringName, ProjectSettings::AutoloadInfo> &E : autoloads) {
const ProjectSettings::AutoloadInfo &info = E.value;

View file

@ -49,7 +49,7 @@
namespace GDScriptTests {
void init_autoloads() {
HashMap<StringName, ProjectSettings::AutoloadInfo> autoloads = ProjectSettings::get_singleton()->get_autoload_list();
HashMap<StringName, ProjectSettings::AutoloadInfo> autoloads(ProjectSettings::get_singleton()->get_autoload_list());
// First pass, add the constants so they exist before any script is loaded.
for (const KeyValue<StringName, ProjectSettings::AutoloadInfo> &E : ProjectSettings::get_singleton()->get_autoload_list()) {

View file

@ -1114,7 +1114,7 @@ void GridMap::_queue_octants_dirty() {
void GridMap::_recreate_octant_data() {
recreating_octants = true;
HashMap<IndexKey, Cell, IndexKey> cell_copy = cell_map;
HashMap<IndexKey, Cell, IndexKey> cell_copy(cell_map);
_clear_internal();
for (const KeyValue<IndexKey, Cell> &E : cell_copy) {
set_cell_item(Vector3i(E.key), E.value.item, E.value.rot);

View file

@ -75,7 +75,7 @@ void JoltShape3D::remove_owner(JoltShapedObject3D *p_owner) {
void JoltShape3D::remove_self() {
// `remove_owner` will be called when we `remove_shape`, so we need to copy the map since the
// iterator would be invalidated from underneath us.
const HashMap<JoltShapedObject3D *, int> ref_counts_by_owner_copy = ref_counts_by_owner;
const HashMap<JoltShapedObject3D *, int> ref_counts_by_owner_copy(ref_counts_by_owner);
for (const KeyValue<JoltShapedObject3D *, int> &E : ref_counts_by_owner_copy) {
E.key->remove_shape(this);

View file

@ -123,7 +123,7 @@ PackedStringArray get_code_completion(CompletionKind p_kind, const String &p_scr
case CompletionKind::NODE_PATHS: {
{
// Autoloads.
HashMap<StringName, ProjectSettings::AutoloadInfo> autoloads = ProjectSettings::get_singleton()->get_autoload_list();
HashMap<StringName, ProjectSettings::AutoloadInfo> autoloads(ProjectSettings::get_singleton()->get_autoload_list());
for (const KeyValue<StringName, ProjectSettings::AutoloadInfo> &E : autoloads) {
const ProjectSettings::AutoloadInfo &info = E.value;

View file

@ -357,7 +357,7 @@ void Area2D::_clear_monitoring() {
ERR_FAIL_COND_MSG(locked, "This function can't be used during the in/out signal.");
{
HashMap<ObjectID, BodyState> bmcopy = body_map;
HashMap<ObjectID, BodyState> bmcopy(body_map);
body_map.clear();
//disconnect all monitored stuff
@ -385,7 +385,7 @@ void Area2D::_clear_monitoring() {
}
{
HashMap<ObjectID, AreaState> bmcopy = area_map;
HashMap<ObjectID, AreaState> bmcopy(area_map);
area_map.clear();
//disconnect all monitored stuff

View file

@ -147,7 +147,7 @@ Vector<int> TileMap::_get_tile_map_data_using_compatibility_format(int p_layer)
ERR_FAIL_INDEX_V(p_layer, (int)layers.size(), Vector<int>());
// Export tile data to raw format.
const HashMap<Vector2i, CellData> tile_map_layer_data = layers[p_layer]->get_tile_map_layer_data();
const HashMap<Vector2i, CellData> tile_map_layer_data(layers[p_layer]->get_tile_map_layer_data());
Vector<int> tile_data;
tile_data.resize(tile_map_layer_data.size() * 3);
int *w = tile_data.ptrw();

View file

@ -303,7 +303,7 @@ void Area3D::_clear_monitoring() {
ERR_FAIL_COND_MSG(locked, "This function can't be used during the in/out signal.");
{
HashMap<ObjectID, BodyState> bmcopy = body_map;
HashMap<ObjectID, BodyState> bmcopy(body_map);
body_map.clear();
//disconnect all monitored stuff
@ -332,7 +332,7 @@ void Area3D::_clear_monitoring() {
}
{
HashMap<ObjectID, AreaState> bmcopy = area_map;
HashMap<ObjectID, AreaState> bmcopy(area_map);
area_map.clear();
//disconnect all monitored stuff

View file

@ -2226,7 +2226,7 @@ Ref<AnimatedValuesBackup> AnimationMixer::make_backup() {
make_animation_instance(SceneStringName(RESET), pi);
_build_backup_track_cache();
backup->set_data(track_cache);
backup->set_data(AHashMap<Animation::TypeHash, TrackCache *, HashHasher>(track_cache));
clear_animation_instances();
return backup;

View file

@ -3499,7 +3499,7 @@ void Node::get_argument_options(const StringName &p_function, int p_idx, List<St
if (p_idx == 0 && (pf == "has_node" || pf == "get_node" || pf == "get_node_or_null")) {
_add_nodes_to_options(this, this, r_options);
} else if (p_idx == 0 && (pf == "add_to_group" || pf == "remove_from_group" || pf == "is_in_group")) {
HashMap<StringName, String> global_groups = ProjectSettings::get_singleton()->get_global_groups_list();
HashMap<StringName, String> global_groups(ProjectSettings::get_singleton()->get_global_groups_list());
for (const KeyValue<StringName, String> &E : global_groups) {
r_options->push_back(E.key.operator String().quote());
}

View file

@ -2008,7 +2008,7 @@ void SceneTree::get_argument_options(const StringName &p_function, int p_idx, Li
add_options = names.has(p_function);
}
if (add_options) {
HashMap<StringName, String> global_groups = ProjectSettings::get_singleton()->get_global_groups_list();
HashMap<StringName, String> global_groups(ProjectSettings::get_singleton()->get_global_groups_list());
for (const KeyValue<StringName, String> &E : global_groups) {
r_options->push_back(E.key.operator String().quote());
}

View file

@ -11616,7 +11616,7 @@ Error ShaderLanguage::complete(const String &p_code, const ShaderCompileInfo &p_
if (comp_ident) {
if (is_shader_inc) {
for (int i = 0; i < RenderingServer::SHADER_MAX; i++) {
const HashMap<StringName, ShaderLanguage::FunctionInfo> info = ShaderTypes::get_singleton()->get_functions(RenderingServer::ShaderMode(i));
const HashMap<StringName, ShaderLanguage::FunctionInfo> &info = ShaderTypes::get_singleton()->get_functions(RenderingServer::ShaderMode(i));
if (info.has("global")) {
for (const KeyValue<StringName, BuiltInInfo> &E : info["global"].built_ins) {

View file

@ -137,7 +137,7 @@ TEST_CASE("[AHashMap] Const iteration") {
map.insert(123485, 1238888);
map.insert(123, 111111);
const AHashMap<int, int> const_map = map;
const AHashMap<int, int> const_map(map);
Vector<Pair<int, int>> expected;
expected.push_back(Pair<int, int>(42, 84));

View file

@ -130,7 +130,7 @@ TEST_CASE("[HashMap] Const iteration") {
map.insert(123485, 1238888);
map.insert(123, 111111);
const HashMap<int, int> const_map = map;
const HashMap<int, int> const_map(map);
Vector<Pair<int, int>> expected;
expected.push_back(Pair<int, int>(42, 84));