diff --git a/core/string/translation_domain.cpp b/core/string/translation_domain.cpp index e7b713d4f0..90bb24ceed 100644 --- a/core/string/translation_domain.cpp +++ b/core/string/translation_domain.cpp @@ -286,7 +286,7 @@ void TranslationDomain::clear() { } const HashSet> TranslationDomain::get_translations() const { - return translations; + return HashSet>(translations); } HashSet> TranslationDomain::find_translations(const String &p_locale, bool p_exact) const { diff --git a/core/templates/hash_set.h b/core/templates/hash_set.h index 056650707b..f266322052 100644 --- a/core/templates/hash_set.h +++ b/core/templates/hash_set.h @@ -417,7 +417,7 @@ public: /* Constructors */ - HashSet(const HashSet &p_other) { + explicit HashSet(const HashSet &p_other) { _init_from(p_other); } diff --git a/editor/export/editor_export_preset.cpp b/editor/export/editor_export_preset.cpp index da07c14f65..bf118faad1 100644 --- a/editor/export/editor_export_preset.cpp +++ b/editor/export/editor_export_preset.cpp @@ -260,7 +260,7 @@ Vector EditorExportPreset::get_files_to_export() const { } HashSet EditorExportPreset::get_selected_files() const { - return selected_files; + return HashSet(selected_files); } void EditorExportPreset::set_selected_files(const HashSet &p_files) { diff --git a/editor/file_system/editor_file_system.cpp b/editor/file_system/editor_file_system.cpp index 4087005924..271d12085e 100644 --- a/editor/file_system/editor_file_system.cpp +++ b/editor/file_system/editor_file_system.cpp @@ -2544,7 +2544,7 @@ void EditorFileSystem::_notify_filesystem_changed() { } HashSet EditorFileSystem::get_valid_extensions() const { - return valid_extensions; + return HashSet(valid_extensions); } void EditorFileSystem::_register_global_class_script(const String &p_search_path, const String &p_target_path, const ScriptClassInfoUpdate &p_script_update) { diff --git a/editor/inspector/editor_resource_picker.cpp b/editor/inspector/editor_resource_picker.cpp index ad40f408e8..df57922336 100644 --- a/editor/inspector/editor_resource_picker.cpp +++ b/editor/inspector/editor_resource_picker.cpp @@ -647,7 +647,7 @@ void EditorResourcePicker::set_create_options(Object *p_menu_node) { int idx = 0; _ensure_allowed_types(); - HashSet allowed_types = allowed_types_without_convert; + HashSet allowed_types(allowed_types_without_convert); if (!allowed_types.is_empty()) { edit_menu->add_separator(TTRC("New")); } @@ -871,7 +871,7 @@ bool EditorResourcePicker::_is_drop_valid(const Dictionary &p_drag_data) const { } _ensure_allowed_types(); - HashSet allowed_types = allowed_types_with_convert; + HashSet allowed_types(allowed_types_with_convert); String res_type = _get_resource_type(res); @@ -966,7 +966,7 @@ void EditorResourcePicker::drop_data_fw(const Point2 &p_point, const Variant &p_ Ref dropped_resource = _get_dropped_resource(p_data); if (dropped_resource.is_valid()) { _ensure_allowed_types(); - HashSet allowed_types = allowed_types_without_convert; + HashSet allowed_types(allowed_types_without_convert); String res_type = _get_resource_type(dropped_resource); @@ -1110,7 +1110,7 @@ void EditorResourcePicker::set_base_type(const String &p_base_type) { // Keep the value, but warn the user that there is a potential mistake. if (!base_type.is_empty() && edited_resource.is_valid()) { _ensure_allowed_types(); - HashSet allowed_types = allowed_types_with_convert; + HashSet allowed_types(allowed_types_with_convert); StringName custom_class; bool is_custom = false; @@ -1132,7 +1132,7 @@ String EditorResourcePicker::get_base_type() const { Vector EditorResourcePicker::get_allowed_types() const { _ensure_allowed_types(); - HashSet allowed_types = allowed_types_without_convert; + HashSet allowed_types(allowed_types_without_convert); Vector types; types.resize(allowed_types.size()); @@ -1154,7 +1154,7 @@ bool EditorResourcePicker::is_resource_allowed(const Ref &p_resource) if (!base_type.is_empty()) { _ensure_allowed_types(); - HashSet allowed_types = allowed_types_with_convert; + HashSet allowed_types(allowed_types_with_convert); StringName custom_class; bool is_custom = false; diff --git a/editor/themes/editor_icons.cpp b/editor/themes/editor_icons.cpp index 33ad89b9a9..a58ad3a7e7 100644 --- a/editor/themes/editor_icons.cpp +++ b/editor/themes/editor_icons.cpp @@ -105,7 +105,7 @@ void editor_register_icons(const Ref &p_theme, bool p_dark_theme, float p Dictionary color_conversion_map = p_dark_theme ? color_conversion_map_dark : color_conversion_map_light; // The names of the icons to exclude from the standard color conversion. - HashSet conversion_exceptions = EditorColorMap::get_color_conversion_exceptions(); + HashSet conversion_exceptions(EditorColorMap::get_color_conversion_exceptions()); // The names of the icons to exclude when adjusting for saturation. HashSet saturation_exceptions; diff --git a/modules/gdscript/gdscript.cpp b/modules/gdscript/gdscript.cpp index b761777337..f4e4fe59b1 100644 --- a/modules/gdscript/gdscript.cpp +++ b/modules/gdscript/gdscript.cpp @@ -644,7 +644,7 @@ void GDScript::_update_exports_down(bool p_base_exports_changed) { return; } - HashSet copy = inheriters_cache; //might get modified + HashSet copy(inheriters_cache); //might get modified for (const ObjectID &E : copy) { Object *id = ObjectDB::get_instance(E); diff --git a/modules/gdscript/gdscript_cache.cpp b/modules/gdscript/gdscript_cache.cpp index 947ca07dff..84c7b66a7e 100644 --- a/modules/gdscript/gdscript_cache.cpp +++ b/modules/gdscript/gdscript_cache.cpp @@ -259,7 +259,7 @@ void GDScriptCache::remove_parser(const String &p_path) { singleton->parser_map.erase(p_path); // Have to copy while iterating, because parser_inverse_dependencies is modified. - HashSet ideps = singleton->parser_inverse_dependencies[p_path]; + HashSet ideps(singleton->parser_inverse_dependencies[p_path]); singleton->parser_inverse_dependencies.erase(p_path); for (String idep_path : ideps) { remove_parser(idep_path); @@ -427,7 +427,7 @@ Error GDScriptCache::finish_compiling(const String &p_owner) { singleton->full_gdscript_cache[p_owner] = script; singleton->shallow_gdscript_cache.erase(p_owner); - HashSet depends = singleton->dependencies[p_owner]; + HashSet depends(singleton->dependencies[p_owner]); Error err = OK; for (const String &E : depends) { diff --git a/modules/multiplayer/scene_multiplayer.h b/modules/multiplayer/scene_multiplayer.h index 23a216786b..d95c89c48c 100644 --- a/modules/multiplayer/scene_multiplayer.h +++ b/modules/multiplayer/scene_multiplayer.h @@ -182,7 +182,7 @@ public: Error send_bytes(Vector p_data, int p_to = MultiplayerPeer::TARGET_PEER_BROADCAST, MultiplayerPeer::TransferMode p_mode = MultiplayerPeer::TRANSFER_MODE_RELIABLE, int p_channel = 0); String get_rpc_md5(const Object *p_obj); - const HashSet get_connected_peers() const { return connected_peers; } + const HashSet get_connected_peers() const { return HashSet(connected_peers); } void set_remote_sender_override(int p_id) { remote_sender_override = p_id; } void set_refuse_new_connections(bool p_refuse); diff --git a/modules/multiplayer/scene_replication_interface.cpp b/modules/multiplayer/scene_replication_interface.cpp index 14eb59baf8..0ca97ea456 100644 --- a/modules/multiplayer/scene_replication_interface.cpp +++ b/modules/multiplayer/scene_replication_interface.cpp @@ -142,7 +142,7 @@ void SceneReplicationInterface::on_network_process() { // Process syncs. uint64_t usec = OS::get_singleton()->get_ticks_usec(); for (KeyValue &E : peers_info) { - const HashSet to_sync = E.value.sync_nodes; + const HashSet to_sync(E.value.sync_nodes); if (to_sync.is_empty()) { continue; // Nothing to sync } @@ -386,7 +386,7 @@ Error SceneReplicationInterface::_update_spawn_visibility(int p_peer, const Obje ERR_FAIL_NULL_V(spawner, ERR_BUG); ERR_FAIL_COND_V(!_has_authority(spawner), ERR_BUG); ERR_FAIL_COND_V(!tracked_nodes.has(p_oid), ERR_BUG); - const HashSet synchronizers = tracked_nodes[p_oid].synchronizers; + const HashSet synchronizers(tracked_nodes[p_oid].synchronizers); bool is_visible = true; for (const ObjectID &sid : synchronizers) { MultiplayerSynchronizer *sync = get_id_as(sid); @@ -490,7 +490,7 @@ Error SceneReplicationInterface::_make_spawn_packet(Node *p_node, MultiplayerSpa // Prepare spawn state. List state_props; List sync_ids; - const HashSet synchronizers = tnode->synchronizers; + const HashSet synchronizers(tnode->synchronizers); for (const ObjectID &sid : synchronizers) { MultiplayerSynchronizer *sync = get_id_as(sid); if (!_has_authority(sync)) { diff --git a/modules/objectdb_profiler/editor/snapshot_data.cpp b/modules/objectdb_profiler/editor/snapshot_data.cpp index c4aa6e4970..d3154b5fd8 100644 --- a/modules/objectdb_profiler/editor/snapshot_data.cpp +++ b/modules/objectdb_profiler/editor/snapshot_data.cpp @@ -275,11 +275,11 @@ void GameStateSnapshot::_get_rc_cycles( SnapshotDataObject *next = objects[next_child.value]; if (next != nullptr && next->is_class(RefCounted::get_class_static()) && !next->is_class(WeakRef::get_class_static()) && !p_traversed_objs.has(next)) { - HashSet traversed_copy = p_traversed_objs; + HashSet traversed_copy(p_traversed_objs); if (p_obj != p_source_obj) { traversed_copy.insert(p_obj); } - _get_rc_cycles(next, p_source_obj, traversed_copy, r_ret_val, child_path); + _get_rc_cycles(next, p_source_obj, std::move(traversed_copy), r_ret_val, child_path); } } } @@ -310,10 +310,9 @@ void GameStateSnapshot::recompute_references() { if (!obj.value->is_class(RefCounted::get_class_static()) || obj.value->is_class(WeakRef::get_class_static())) { continue; } - HashSet traversed_objs; LocalVector cycles; - _get_rc_cycles(obj.value, obj.value, traversed_objs, cycles, ""); + _get_rc_cycles(obj.value, obj.value, HashSet(), cycles, ""); Array cycles_array; for (const String &cycle : cycles) { cycles_array.push_back(cycle); diff --git a/scene/2d/audio_stream_player_2d.cpp b/scene/2d/audio_stream_player_2d.cpp index 4f7e8eaaaf..63e44aecbd 100644 --- a/scene/2d/audio_stream_player_2d.cpp +++ b/scene/2d/audio_stream_player_2d.cpp @@ -125,7 +125,7 @@ void AudioStreamPlayer2D::_update_panning() { Vector2 global_pos = get_global_position(); - HashSet viewports = world_2d->get_viewports(); + HashSet viewports(world_2d->get_viewports()); volume_vector.resize(4); volume_vector.write[0] = AudioFrame(0, 0); diff --git a/scene/3d/audio_stream_player_3d.cpp b/scene/3d/audio_stream_player_3d.cpp index cfc00d206f..db53082810 100644 --- a/scene/3d/audio_stream_player_3d.cpp +++ b/scene/3d/audio_stream_player_3d.cpp @@ -378,7 +378,7 @@ Vector AudioStreamPlayer3D::_update_panning() { Ref world_3d = get_world_3d(); ERR_FAIL_COND_V(world_3d.is_null(), output_volume_vector); - HashSet cameras = world_3d->get_cameras(); + HashSet cameras(world_3d->get_cameras()); cameras.insert(get_viewport()->get_camera_3d()); #ifndef PHYSICS_3D_DISABLED diff --git a/scene/gui/graph_edit_arranger.cpp b/scene/gui/graph_edit_arranger.cpp index 08a71c2aff..1c21ba978a 100644 --- a/scene/gui/graph_edit_arranger.cpp +++ b/scene/gui/graph_edit_arranger.cpp @@ -242,14 +242,17 @@ int GraphEditArranger::_set_operations(SET_OPERATIONS p_operation, HashSet> GraphEditArranger::_layering(const HashSet &r_selected_nodes, const HashMap> &r_upper_neighbours) { HashMap> l; - HashSet p = r_selected_nodes, q = r_selected_nodes, u, z; + HashSet p(r_selected_nodes); + HashSet q(r_selected_nodes); + HashSet u; + HashSet z; int current_layer = 0; bool selected = false; while (!_set_operations(GraphEditArranger::IS_EQUAL, q, u)) { _set_operations(GraphEditArranger::DIFFERENCE, p, u); for (const StringName &E : p) { - HashSet n = r_upper_neighbours[E]; + HashSet n(r_upper_neighbours[E]); if (_set_operations(GraphEditArranger::IS_SUBSET, n, z)) { Vector t; t.push_back(E); diff --git a/scene/main/window.h b/scene/main/window.h index 986e213a7e..84a872ac1e 100644 --- a/scene/main/window.h +++ b/scene/main/window.h @@ -413,7 +413,7 @@ public: void child_controls_changed(); Window *get_exclusive_child() const { return exclusive_child; } - HashSet get_transient_children() const { return transient_children; } + const HashSet &get_transient_children() const { return transient_children; } Window *get_parent_visible_window() const; Window *get_non_popup_window() const; Viewport *get_parent_viewport() const; diff --git a/tests/core/templates/test_hash_set.h b/tests/core/templates/test_hash_set.h index d4b5e4987a..81b3026a5b 100644 --- a/tests/core/templates/test_hash_set.h +++ b/tests/core/templates/test_hash_set.h @@ -221,7 +221,8 @@ TEST_CASE("[HashSet] Copy") { expected.push_back(0); expected.push_back(123485); - HashSet copy_assign = set; + HashSet copy_assign; + copy_assign = set; int idx = 0; for (const int &E : copy_assign) {