Merge pull request #116381 from Ivorforce/hashset-explicit-copy
Change `HashSet` copy constructor from implicit to explicit.
This commit is contained in:
commit
23d7147d1e
16 changed files with 31 additions and 28 deletions
|
|
@ -286,7 +286,7 @@ void TranslationDomain::clear() {
|
|||
}
|
||||
|
||||
const HashSet<Ref<Translation>> TranslationDomain::get_translations() const {
|
||||
return translations;
|
||||
return HashSet<Ref<Translation>>(translations);
|
||||
}
|
||||
|
||||
HashSet<Ref<Translation>> TranslationDomain::find_translations(const String &p_locale, bool p_exact) const {
|
||||
|
|
|
|||
|
|
@ -417,7 +417,7 @@ public:
|
|||
|
||||
/* Constructors */
|
||||
|
||||
HashSet(const HashSet &p_other) {
|
||||
explicit HashSet(const HashSet &p_other) {
|
||||
_init_from(p_other);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -260,7 +260,7 @@ Vector<String> EditorExportPreset::get_files_to_export() const {
|
|||
}
|
||||
|
||||
HashSet<String> EditorExportPreset::get_selected_files() const {
|
||||
return selected_files;
|
||||
return HashSet<String>(selected_files);
|
||||
}
|
||||
|
||||
void EditorExportPreset::set_selected_files(const HashSet<String> &p_files) {
|
||||
|
|
|
|||
|
|
@ -2544,7 +2544,7 @@ void EditorFileSystem::_notify_filesystem_changed() {
|
|||
}
|
||||
|
||||
HashSet<String> EditorFileSystem::get_valid_extensions() const {
|
||||
return valid_extensions;
|
||||
return HashSet<String>(valid_extensions);
|
||||
}
|
||||
|
||||
void EditorFileSystem::_register_global_class_script(const String &p_search_path, const String &p_target_path, const ScriptClassInfoUpdate &p_script_update) {
|
||||
|
|
|
|||
|
|
@ -647,7 +647,7 @@ void EditorResourcePicker::set_create_options(Object *p_menu_node) {
|
|||
int idx = 0;
|
||||
|
||||
_ensure_allowed_types();
|
||||
HashSet<StringName> allowed_types = allowed_types_without_convert;
|
||||
HashSet<StringName> 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<StringName> allowed_types = allowed_types_with_convert;
|
||||
HashSet<StringName> 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<Resource> dropped_resource = _get_dropped_resource(p_data);
|
||||
if (dropped_resource.is_valid()) {
|
||||
_ensure_allowed_types();
|
||||
HashSet<StringName> allowed_types = allowed_types_without_convert;
|
||||
HashSet<StringName> 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<StringName> allowed_types = allowed_types_with_convert;
|
||||
HashSet<StringName> allowed_types(allowed_types_with_convert);
|
||||
|
||||
StringName custom_class;
|
||||
bool is_custom = false;
|
||||
|
|
@ -1132,7 +1132,7 @@ String EditorResourcePicker::get_base_type() const {
|
|||
|
||||
Vector<String> EditorResourcePicker::get_allowed_types() const {
|
||||
_ensure_allowed_types();
|
||||
HashSet<StringName> allowed_types = allowed_types_without_convert;
|
||||
HashSet<StringName> allowed_types(allowed_types_without_convert);
|
||||
|
||||
Vector<String> types;
|
||||
types.resize(allowed_types.size());
|
||||
|
|
@ -1154,7 +1154,7 @@ bool EditorResourcePicker::is_resource_allowed(const Ref<Resource> &p_resource)
|
|||
|
||||
if (!base_type.is_empty()) {
|
||||
_ensure_allowed_types();
|
||||
HashSet<StringName> allowed_types = allowed_types_with_convert;
|
||||
HashSet<StringName> allowed_types(allowed_types_with_convert);
|
||||
|
||||
StringName custom_class;
|
||||
bool is_custom = false;
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ void editor_register_icons(const Ref<Theme> &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<StringName> conversion_exceptions = EditorColorMap::get_color_conversion_exceptions();
|
||||
HashSet<StringName> conversion_exceptions(EditorColorMap::get_color_conversion_exceptions());
|
||||
|
||||
// The names of the icons to exclude when adjusting for saturation.
|
||||
HashSet<StringName> saturation_exceptions;
|
||||
|
|
|
|||
|
|
@ -644,7 +644,7 @@ void GDScript::_update_exports_down(bool p_base_exports_changed) {
|
|||
return;
|
||||
}
|
||||
|
||||
HashSet<ObjectID> copy = inheriters_cache; //might get modified
|
||||
HashSet<ObjectID> copy(inheriters_cache); //might get modified
|
||||
|
||||
for (const ObjectID &E : copy) {
|
||||
Object *id = ObjectDB::get_instance(E);
|
||||
|
|
|
|||
|
|
@ -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<String> ideps = singleton->parser_inverse_dependencies[p_path];
|
||||
HashSet<String> 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<String> depends = singleton->dependencies[p_owner];
|
||||
HashSet<String> depends(singleton->dependencies[p_owner]);
|
||||
|
||||
Error err = OK;
|
||||
for (const String &E : depends) {
|
||||
|
|
|
|||
|
|
@ -182,7 +182,7 @@ public:
|
|||
Error send_bytes(Vector<uint8_t> 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<int> get_connected_peers() const { return connected_peers; }
|
||||
const HashSet<int> get_connected_peers() const { return HashSet<int>(connected_peers); }
|
||||
|
||||
void set_remote_sender_override(int p_id) { remote_sender_override = p_id; }
|
||||
void set_refuse_new_connections(bool p_refuse);
|
||||
|
|
|
|||
|
|
@ -142,7 +142,7 @@ void SceneReplicationInterface::on_network_process() {
|
|||
// Process syncs.
|
||||
uint64_t usec = OS::get_singleton()->get_ticks_usec();
|
||||
for (KeyValue<int, PeerInfo> &E : peers_info) {
|
||||
const HashSet<ObjectID> to_sync = E.value.sync_nodes;
|
||||
const HashSet<ObjectID> 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<ObjectID> synchronizers = tracked_nodes[p_oid].synchronizers;
|
||||
const HashSet<ObjectID> synchronizers(tracked_nodes[p_oid].synchronizers);
|
||||
bool is_visible = true;
|
||||
for (const ObjectID &sid : synchronizers) {
|
||||
MultiplayerSynchronizer *sync = get_id_as<MultiplayerSynchronizer>(sid);
|
||||
|
|
@ -490,7 +490,7 @@ Error SceneReplicationInterface::_make_spawn_packet(Node *p_node, MultiplayerSpa
|
|||
// Prepare spawn state.
|
||||
List<NodePath> state_props;
|
||||
List<uint32_t> sync_ids;
|
||||
const HashSet<ObjectID> synchronizers = tnode->synchronizers;
|
||||
const HashSet<ObjectID> synchronizers(tnode->synchronizers);
|
||||
for (const ObjectID &sid : synchronizers) {
|
||||
MultiplayerSynchronizer *sync = get_id_as<MultiplayerSynchronizer>(sid);
|
||||
if (!_has_authority(sync)) {
|
||||
|
|
|
|||
|
|
@ -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<SnapshotDataObject *> traversed_copy = p_traversed_objs;
|
||||
HashSet<SnapshotDataObject *> 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<SnapshotDataObject *> traversed_objs;
|
||||
LocalVector<String> cycles;
|
||||
|
||||
_get_rc_cycles(obj.value, obj.value, traversed_objs, cycles, "");
|
||||
_get_rc_cycles(obj.value, obj.value, HashSet<SnapshotDataObject *>(), cycles, "");
|
||||
Array cycles_array;
|
||||
for (const String &cycle : cycles) {
|
||||
cycles_array.push_back(cycle);
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@ void AudioStreamPlayer2D::_update_panning() {
|
|||
|
||||
Vector2 global_pos = get_global_position();
|
||||
|
||||
HashSet<Viewport *> viewports = world_2d->get_viewports();
|
||||
HashSet<Viewport *> viewports(world_2d->get_viewports());
|
||||
|
||||
volume_vector.resize(4);
|
||||
volume_vector.write[0] = AudioFrame(0, 0);
|
||||
|
|
|
|||
|
|
@ -378,7 +378,7 @@ Vector<AudioFrame> AudioStreamPlayer3D::_update_panning() {
|
|||
Ref<World3D> world_3d = get_world_3d();
|
||||
ERR_FAIL_COND_V(world_3d.is_null(), output_volume_vector);
|
||||
|
||||
HashSet<Camera3D *> cameras = world_3d->get_cameras();
|
||||
HashSet<Camera3D *> cameras(world_3d->get_cameras());
|
||||
cameras.insert(get_viewport()->get_camera_3d());
|
||||
|
||||
#ifndef PHYSICS_3D_DISABLED
|
||||
|
|
|
|||
|
|
@ -242,14 +242,17 @@ int GraphEditArranger::_set_operations(SET_OPERATIONS p_operation, HashSet<Strin
|
|||
HashMap<int, Vector<StringName>> GraphEditArranger::_layering(const HashSet<StringName> &r_selected_nodes, const HashMap<StringName, HashSet<StringName>> &r_upper_neighbours) {
|
||||
HashMap<int, Vector<StringName>> l;
|
||||
|
||||
HashSet<StringName> p = r_selected_nodes, q = r_selected_nodes, u, z;
|
||||
HashSet<StringName> p(r_selected_nodes);
|
||||
HashSet<StringName> q(r_selected_nodes);
|
||||
HashSet<StringName> u;
|
||||
HashSet<StringName> 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<StringName> n = r_upper_neighbours[E];
|
||||
HashSet<StringName> n(r_upper_neighbours[E]);
|
||||
if (_set_operations(GraphEditArranger::IS_SUBSET, n, z)) {
|
||||
Vector<StringName> t;
|
||||
t.push_back(E);
|
||||
|
|
|
|||
|
|
@ -413,7 +413,7 @@ public:
|
|||
void child_controls_changed();
|
||||
|
||||
Window *get_exclusive_child() const { return exclusive_child; }
|
||||
HashSet<Window *> get_transient_children() const { return transient_children; }
|
||||
const HashSet<Window *> &get_transient_children() const { return transient_children; }
|
||||
Window *get_parent_visible_window() const;
|
||||
Window *get_non_popup_window() const;
|
||||
Viewport *get_parent_viewport() const;
|
||||
|
|
|
|||
|
|
@ -221,7 +221,8 @@ TEST_CASE("[HashSet] Copy") {
|
|||
expected.push_back(0);
|
||||
expected.push_back(123485);
|
||||
|
||||
HashSet<int> copy_assign = set;
|
||||
HashSet<int> copy_assign;
|
||||
copy_assign = set;
|
||||
|
||||
int idx = 0;
|
||||
for (const int &E : copy_assign) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue