From 92299989bd10fd9855b6d77bc2bfabae218d1eea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Mon, 26 Jul 2021 17:50:35 +0200 Subject: [PATCH] Use Ref references as iterators where relevant And const when possible. --- core/core_bind.cpp | 14 ++++----- editor/editor_inspector.cpp | 10 +++---- editor/editor_node.cpp | 29 +++---------------- editor/editor_settings.cpp | 4 +-- editor/filesystem_dock.cpp | 2 +- editor/import/resource_importer_obj.cpp | 2 +- editor/import_defaults_editor.cpp | 4 +-- editor/import_dock.cpp | 4 +-- .../plugins/sprite_frames_editor_plugin.cpp | 2 +- editor/plugins/theme_editor_plugin.cpp | 2 +- editor/settings_config_dialog.cpp | 2 +- modules/gdscript/gdscript.cpp | 28 +++++++++--------- modules/mono/csharp_script.cpp | 10 +++---- modules/webrtc/webrtc_multiplayer_peer.cpp | 10 +++---- modules/websocket/wsl_server.cpp | 4 +-- scene/animation/tween.cpp | 8 ++--- scene/main/scene_tree.cpp | 8 ++--- scene/main/viewport.cpp | 2 +- 18 files changed, 62 insertions(+), 83 deletions(-) diff --git a/core/core_bind.cpp b/core/core_bind.cpp index 12fca4215ac..9e96d4b0794 100644 --- a/core/core_bind.cpp +++ b/core/core_bind.cpp @@ -355,20 +355,20 @@ void _OS::print_all_textures_by_size() { List> rsrc; ResourceCache::get_cached_resources(&rsrc); - for (Ref E : rsrc) { - if (!E->is_class("ImageTexture")) { + for (Ref &res : rsrc) { + if (!res->is_class("ImageTexture")) { continue; } - Size2 size = E->call("get_size"); - int fmt = E->call("get_format"); + Size2 size = res->call("get_size"); + int fmt = res->call("get_format"); _OSCoreBindImg img; img.size = size; img.fmt = fmt; - img.path = E->get_path(); + img.path = res->get_path(); img.vram = Image::get_image_data_size(img.size.width, img.size.height, Image::Format(img.fmt)); - img.id = E->get_instance_id(); + img.id = res->get_instance_id(); total += img.vram; imgs.push_back(img); } @@ -387,7 +387,7 @@ void _OS::print_resources_by_type(const Vector &p_types) { List> resources; ResourceCache::get_cached_resources(&resources); - for (Ref r : resources) { + for (const Ref &r : resources) { bool found = false; for (int i = 0; i < p_types.size(); i++) { diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp index cdbe505441e..3db03c02761 100644 --- a/editor/editor_inspector.cpp +++ b/editor/editor_inspector.cpp @@ -1648,7 +1648,7 @@ void EditorInspector::update_tree() { Color sscolor = get_theme_color(SNAME("prop_subsection"), SNAME("Editor")); - for (Ref ped : valid_plugins) { + for (Ref &ped : valid_plugins) { ped->parse_begin(object); _parse_added_editors(main_vbox, ped); } @@ -1745,7 +1745,7 @@ void EditorInspector::update_tree() { category->set_tooltip(p.name + "::" + (class_descr_cache[type2] == "" ? "" : class_descr_cache[type2])); } - for (Ref ped : valid_plugins) { + for (Ref &ped : valid_plugins) { ped->parse_category(object, p.name); _parse_added_editors(main_vbox, ped); } @@ -1946,7 +1946,7 @@ void EditorInspector::update_tree() { doc_hint = descr; } - for (Ref ped : valid_plugins) { + for (Ref &ped : valid_plugins) { bool exclusive = ped->parse_property(object, p.type, p.name, p.hint, p.hint_string, p.usage, wide_editors); List editors = ped->added_editors; //make a copy, since plugins may be used again in a sub-inspector @@ -2028,7 +2028,7 @@ void EditorInspector::update_tree() { } } - for (Ref ped : valid_plugins) { + for (Ref &ped : valid_plugins) { ped->parse_end(); _parse_added_editors(main_vbox, ped); } @@ -2595,7 +2595,7 @@ void EditorInspector::_update_script_class_properties(const Object &p_object, Li } Set added; - for (Ref