diff --git a/core/object/object.cpp b/core/object/object.cpp index 40df13849bd..5a776e2106c 100644 --- a/core/object/object.cpp +++ b/core/object/object.cpp @@ -1347,12 +1347,10 @@ Error Object::connect(const StringName &p_signal, const Callable &p_callable, ui s = &signal_map[p_signal]; } - Callable target = p_callable; - //compare with the base callable, so binds can be ignored - if (s->slot_map.has(*target.get_base_comparator())) { + if (s->slot_map.has(*p_callable.get_base_comparator())) { if (p_flags & CONNECT_REFERENCE_COUNTED) { - s->slot_map[*target.get_base_comparator()].reference_count++; + s->slot_map[*p_callable.get_base_comparator()].reference_count++; return OK; } else { ERR_FAIL_V_MSG(ERR_INVALID_PARAMETER, "Signal '" + p_signal + "' is already connected to given callable '" + p_callable + "' in that object."); @@ -1364,7 +1362,7 @@ Error Object::connect(const StringName &p_signal, const Callable &p_callable, ui SignalData::Slot slot; Connection conn; - conn.callable = target; + conn.callable = p_callable; conn.signal = ::Signal(this, p_signal); conn.flags = p_flags; slot.conn = conn; @@ -1376,7 +1374,7 @@ Error Object::connect(const StringName &p_signal, const Callable &p_callable, ui } //use callable version as key, so binds can be ignored - s->slot_map[*target.get_base_comparator()] = slot; + s->slot_map[*p_callable.get_base_comparator()] = slot; return OK; } @@ -1397,9 +1395,7 @@ bool Object::is_connected(const StringName &p_signal, const Callable &p_callable ERR_FAIL_V_MSG(false, "Nonexistent signal: " + p_signal + "."); } - Callable target = p_callable; - - return s->slot_map.has(*target.get_base_comparator()); + return s->slot_map.has(*p_callable.get_base_comparator()); } void Object::disconnect(const StringName &p_signal, const Callable &p_callable) { diff --git a/editor/animation_track_editor_plugins.cpp b/editor/animation_track_editor_plugins.cpp index 91a0f213ecb..390b722b7b7 100644 --- a/editor/animation_track_editor_plugins.cpp +++ b/editor/animation_track_editor_plugins.cpp @@ -973,8 +973,7 @@ bool AnimationTrackEditTypeAudio::can_drop_data(const Point2 &p_point, const Var Vector files = drag_data["files"]; if (files.size() == 1) { - String file = files[0]; - Ref res = ResourceLoader::load(file); + Ref res = ResourceLoader::load(files[0]); if (res.is_valid()) { return true; } @@ -995,8 +994,7 @@ void AnimationTrackEditTypeAudio::drop_data(const Point2 &p_point, const Variant Vector files = drag_data["files"]; if (files.size() == 1) { - String file = files[0]; - stream = ResourceLoader::load(file); + stream = ResourceLoader::load(files[0]); } } diff --git a/editor/editor_resource_picker.cpp b/editor/editor_resource_picker.cpp index 9b34f09e99e..ed20e50685d 100644 --- a/editor/editor_resource_picker.cpp +++ b/editor/editor_resource_picker.cpp @@ -652,8 +652,7 @@ bool EditorResourcePicker::_is_drop_valid(const Dictionary &p_drag_data) const { // TODO: Extract the typename of the dropped filepath's resource in a more performant way, without fully loading it. if (files.size() == 1) { - String file = files[0]; - res = ResourceLoader::load(file); + res = ResourceLoader::load(files[0]); } } @@ -718,8 +717,7 @@ void EditorResourcePicker::drop_data_fw(const Point2 &p_point, const Variant &p_ Vector files = drag_data["files"]; if (files.size() == 1) { - String file = files[0]; - dropped_resource = ResourceLoader::load(file); + dropped_resource = ResourceLoader::load(files[0]); } } diff --git a/editor/gui/scene_tree_editor.cpp b/editor/gui/scene_tree_editor.cpp index ba4fa994b7d..327b73f993e 100644 --- a/editor/gui/scene_tree_editor.cpp +++ b/editor/gui/scene_tree_editor.cpp @@ -1326,8 +1326,7 @@ bool SceneTreeEditor::can_drop_data_fw(const Point2 &p_point, const Variant &p_d bool scene_drop = true; for (int i = 0; i < files.size(); i++) { - String file = files[i]; - String ftype = EditorFileSystem::get_singleton()->get_file_type(file); + String ftype = EditorFileSystem::get_singleton()->get_file_type(files[i]); if (ftype != "PackedScene") { scene_drop = false; break; diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index 85846d7bc61..bac2a4909fc 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -5613,8 +5613,7 @@ void CanvasItemEditorViewport::_on_change_type_closed() { void CanvasItemEditorViewport::_create_preview(const Vector &files) const { bool add_preview = false; for (int i = 0; i < files.size(); i++) { - String path = files[i]; - Ref res = ResourceLoader::load(path); + Ref res = ResourceLoader::load(files[i]); ERR_FAIL_COND(res.is_null()); Ref texture = Ref(Object::cast_to(*res)); Ref scene = Ref(Object::cast_to(*res)); diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp index ad7ef2b6ef6..52f17c4a457 100644 --- a/editor/plugins/node_3d_editor_plugin.cpp +++ b/editor/plugins/node_3d_editor_plugin.cpp @@ -4154,8 +4154,7 @@ Node *Node3DEditorViewport::_sanitize_preview_node(Node *p_node) const { void Node3DEditorViewport::_create_preview_node(const Vector &files) const { bool add_preview = false; for (int i = 0; i < files.size(); i++) { - String path = files[i]; - Ref res = ResourceLoader::load(path); + Ref res = ResourceLoader::load(files[i]); ERR_CONTINUE(res.is_null()); Ref scene = Ref(Object::cast_to(*res)); Ref mesh = Ref(Object::cast_to(*res)); diff --git a/editor/plugins/tiles/tile_set_editor.cpp b/editor/plugins/tiles/tile_set_editor.cpp index 5bde1f754bb..ef56e66e856 100644 --- a/editor/plugins/tiles/tile_set_editor.cpp +++ b/editor/plugins/tiles/tile_set_editor.cpp @@ -86,8 +86,7 @@ bool TileSetEditor::_can_drop_data_fw(const Point2 &p_point, const Variant &p_da } for (int i = 0; i < files.size(); i++) { - String file = files[i]; - String ftype = EditorFileSystem::get_singleton()->get_file_type(file); + String ftype = EditorFileSystem::get_singleton()->get_file_type(files[i]); if (!ClassDB::is_parent_class(ftype, "Texture2D")) { return false; diff --git a/editor/plugins/tiles/tile_set_scenes_collection_source_editor.cpp b/editor/plugins/tiles/tile_set_scenes_collection_source_editor.cpp index eaf7a2b50b3..1f4c3651e90 100644 --- a/editor/plugins/tiles/tile_set_scenes_collection_source_editor.cpp +++ b/editor/plugins/tiles/tile_set_scenes_collection_source_editor.cpp @@ -479,8 +479,7 @@ bool TileSetScenesCollectionSourceEditor::_can_drop_data_fw(const Point2 &p_poin } for (int i = 0; i < files.size(); i++) { - String file = files[i]; - String ftype = EditorFileSystem::get_singleton()->get_file_type(file); + String ftype = EditorFileSystem::get_singleton()->get_file_type(files[i]); if (!ClassDB::is_parent_class(ftype, "PackedScene")) { return false; diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp index 5cae151531d..5c22e454ab4 100644 --- a/editor/plugins/visual_shader_editor_plugin.cpp +++ b/editor/plugins/visual_shader_editor_plugin.cpp @@ -4826,16 +4826,14 @@ void VisualShaderEditor::_varying_create() { add_varying_dialog->hide(); } -void VisualShaderEditor::_varying_name_changed(const String &p_text) { - String name = p_text; - - if (!name.is_valid_identifier()) { +void VisualShaderEditor::_varying_name_changed(const String &p_name) { + if (!p_name.is_valid_identifier()) { varying_error_label->show(); varying_error_label->set_text(TTR("Invalid name for varying.")); add_varying_dialog->get_ok_button()->set_disabled(true); return; } - if (visual_shader->has_varying(name)) { + if (visual_shader->has_varying(p_name)) { varying_error_label->show(); varying_error_label->set_text(TTR("Varying with that name is already exist.")); add_varying_dialog->get_ok_button()->set_disabled(true); diff --git a/editor/plugins/visual_shader_editor_plugin.h b/editor/plugins/visual_shader_editor_plugin.h index c4ee654b253..5f1fde3a52f 100644 --- a/editor/plugins/visual_shader_editor_plugin.h +++ b/editor/plugins/visual_shader_editor_plugin.h @@ -491,7 +491,7 @@ class VisualShaderEditor : public VBoxContainer { void _member_cancel(); void _varying_create(); - void _varying_name_changed(const String &p_text); + void _varying_name_changed(const String &p_name); void _varying_deleted(); void _varying_selected(); void _varying_unselected(); diff --git a/modules/gdscript/gdscript.cpp b/modules/gdscript/gdscript.cpp index ec1682d4708..07ab99e98bc 100644 --- a/modules/gdscript/gdscript.cpp +++ b/modules/gdscript/gdscript.cpp @@ -1117,8 +1117,7 @@ GDScript *GDScript::find_class(const String &p_qualified_name) { // Starts at index 1 because index 0 was handled above. for (int i = 1; result != nullptr && i < class_names.size(); i++) { - String current_name = class_names[i]; - if (HashMap>::Iterator E = result->subclasses.find(current_name)) { + if (HashMap>::Iterator E = result->subclasses.find(class_names[i])) { result = E->value.ptr(); } else { // Couldn't find inner class. diff --git a/modules/gdscript/language_server/gdscript_text_document.cpp b/modules/gdscript/language_server/gdscript_text_document.cpp index 44f605232dc..0b1371851b4 100644 --- a/modules/gdscript/language_server/gdscript_text_document.cpp +++ b/modules/gdscript/language_server/gdscript_text_document.cpp @@ -315,9 +315,8 @@ Dictionary GDScriptTextDocument::resolve(const Dictionary &p_params) { Vector param_symbols = query.split(SYMBOL_SEPERATOR, false); if (param_symbols.size() >= 2) { - String class_ = param_symbols[0]; - StringName class_name = class_; - String member_name = param_symbols[param_symbols.size() - 1]; + StringName class_name = param_symbols[0]; + const String &member_name = param_symbols[param_symbols.size() - 1]; String inner_class_name; if (param_symbols.size() >= 3) { inner_class_name = param_symbols[1]; diff --git a/platform/ios/export/export_plugin.cpp b/platform/ios/export/export_plugin.cpp index 86c3feb962f..b478759e458 100644 --- a/platform/ios/export/export_plugin.cpp +++ b/platform/ios/export/export_plugin.cpp @@ -893,8 +893,7 @@ Error EditorExportPlatformIOS::_walk_dir_recursive(Ref &p_da, FileHan p_da->list_dir_end(); for (int i = 0; i < dirs.size(); ++i) { - String dir = dirs[i]; - p_da->change_dir(dir); + p_da->change_dir(dirs[i]); Error err = _walk_dir_recursive(p_da, p_handler, p_userdata); p_da->change_dir(".."); if (err) { diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp index 41f4de5b3b1..fbc374e89e8 100644 --- a/scene/gui/rich_text_label.cpp +++ b/scene/gui/rich_text_label.cpp @@ -6331,11 +6331,9 @@ Ref RichTextLabel::_get_custom_effect_by_code(String p_bbcode_id Dictionary RichTextLabel::parse_expressions_for_values(Vector p_expressions) { Dictionary d; for (int i = 0; i < p_expressions.size(); i++) { - String expression = p_expressions[i]; - Array a; - Vector parts = expression.split("=", true); - String key = parts[0]; + Vector parts = p_expressions[i].split("=", true); + const String &key = parts[0]; if (parts.size() != 2) { return d; } diff --git a/scene/gui/tab_bar.cpp b/scene/gui/tab_bar.cpp index 777ca96cc43..e9fbdbb3126 100644 --- a/scene/gui/tab_bar.cpp +++ b/scene/gui/tab_bar.cpp @@ -1664,7 +1664,7 @@ bool TabBar::_set(const StringName &p_name, const Variant &p_value) { } else if (property == "icon") { set_tab_icon(tab_index, p_value); return true; - } else if (components[1] == "disabled") { + } else if (property == "disabled") { set_tab_disabled(tab_index, p_value); return true; } @@ -1683,7 +1683,7 @@ bool TabBar::_get(const StringName &p_name, Variant &r_ret) const { } else if (property == "icon") { r_ret = get_tab_icon(tab_index); return true; - } else if (components[1] == "disabled") { + } else if (property == "disabled") { r_ret = is_tab_disabled(tab_index); return true; } diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 5817f70343a..308250c592e 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -5314,8 +5314,7 @@ int TextEdit::get_line_wrap_index_at_column(int p_line, int p_column) const { Vector lines = get_line_wrapped_text(p_line); for (int i = 0; i < lines.size(); i++) { wrap_index = i; - String s = lines[wrap_index]; - col += s.length(); + col += lines[wrap_index].length(); if (col > p_column) { break; } diff --git a/scene/main/resource_preloader.cpp b/scene/main/resource_preloader.cpp index de42b635489..fe0e82370ac 100644 --- a/scene/main/resource_preloader.cpp +++ b/scene/main/resource_preloader.cpp @@ -40,12 +40,11 @@ void ResourcePreloader::_set_resources(const Array &p_data) { ERR_FAIL_COND(names.size() != resdata.size()); for (int i = 0; i < resdata.size(); i++) { - String name = names[i]; Ref resource = resdata[i]; ERR_CONTINUE(!resource.is_valid()); - resources[name] = resource; + resources[names[i]] = resource; - //add_resource(name,resource); + //add_resource(names[i],resource); } } diff --git a/scene/resources/resource_format_text.cpp b/scene/resources/resource_format_text.cpp index 19718f12be2..3dc920c4be4 100644 --- a/scene/resources/resource_format_text.cpp +++ b/scene/resources/resource_format_text.cpp @@ -973,8 +973,7 @@ Error ResourceLoaderText::rename_dependencies(Ref p_f, const String } if (p_map.has(path)) { - String np = p_map[path]; - path = np; + path = p_map[path]; } if (relative) { diff --git a/servers/rendering/renderer_canvas_cull.cpp b/servers/rendering/renderer_canvas_cull.cpp index fbe4b1adef8..cc51d440428 100644 --- a/servers/rendering/renderer_canvas_cull.cpp +++ b/servers/rendering/renderer_canvas_cull.cpp @@ -1396,14 +1396,12 @@ void RendererCanvasCull::canvas_item_add_triangle_array(RID p_item, const Vector ERR_FAIL_COND(!p_bones.is_empty() && p_bones.size() != vertex_count * 4); ERR_FAIL_COND(!p_weights.is_empty() && p_weights.size() != vertex_count * 4); - Vector indices = p_indices; - Item::CommandPolygon *polygon = canvas_item->alloc_command(); ERR_FAIL_NULL(polygon); polygon->texture = p_texture; - polygon->polygon.create(indices, p_points, p_colors, p_uvs, p_bones, p_weights); + polygon->polygon.create(p_indices, p_points, p_colors, p_uvs, p_bones, p_weights); polygon->primitive = RS::PRIMITIVE_TRIANGLES; }