Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove redundant non-trivial Variant types initializations #68657

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions core/config/project_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ String ProjectSettings::get_imported_files_path() const {
// Returns the features that a project must have when opened with this build of Godot.
// This is used by the project manager to provide the initial_settings for config/features.
const PackedStringArray ProjectSettings::get_required_features() {
PackedStringArray features = PackedStringArray();
PackedStringArray features;
features.append(VERSION_BRANCH);
#ifdef REAL_T_IS_DOUBLE
features.append("Double Precision");
Expand Down Expand Up @@ -115,7 +115,7 @@ const PackedStringArray ProjectSettings::_get_supported_features() {

// Returns the features that this project needs but this build of Godot lacks.
const PackedStringArray ProjectSettings::get_unsupported_features(const PackedStringArray &p_project_features) {
PackedStringArray unsupported_features = PackedStringArray();
PackedStringArray unsupported_features;
PackedStringArray supported_features = singleton->_get_supported_features();
for (int i = 0; i < p_project_features.size(); i++) {
if (!supported_features.has(p_project_features[i])) {
Expand Down Expand Up @@ -1251,7 +1251,7 @@ ProjectSettings::ProjectSettings() {
GLOBAL_DEF_RST("audio/general/3d_panning_strength", 1.0f);
custom_prop_info["audio/general/3d_panning_strength"] = PropertyInfo(Variant::FLOAT, "audio/general/3d_panning_strength", PROPERTY_HINT_RANGE, "0,4,0.01");

PackedStringArray extensions = PackedStringArray();
PackedStringArray extensions;
extensions.push_back("gd");
if (Engine::get_singleton()->has_singleton("GodotSharp")) {
extensions.push_back("cs");
Expand Down
2 changes: 1 addition & 1 deletion core/string/ustring.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2839,7 +2839,7 @@ String String::substr(int p_from, int p_chars) const {
return String(*this);
}

String s = String();
String s;
s.copy_from_unchecked(&get_data()[p_from], p_chars);
return s;
}
Expand Down
4 changes: 2 additions & 2 deletions core/variant/variant_call.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2438,7 +2438,7 @@ static void _register_variant_builtin_methods() {
_VariantCall::add_variant_constant(Variant::TRANSFORM2D, "FLIP_X", Transform2D(-1, 0, 0, 1, 0, 0));
_VariantCall::add_variant_constant(Variant::TRANSFORM2D, "FLIP_Y", Transform2D(1, 0, 0, -1, 0, 0));

Transform3D identity_transform = Transform3D();
Transform3D identity_transform;
Transform3D flip_x_transform = Transform3D(-1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0);
Transform3D flip_y_transform = Transform3D(1, 0, 0, 0, -1, 0, 0, 0, 1, 0, 0, 0);
Transform3D flip_z_transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, -1, 0, 0, 0);
Expand All @@ -2447,7 +2447,7 @@ static void _register_variant_builtin_methods() {
_VariantCall::add_variant_constant(Variant::TRANSFORM3D, "FLIP_Y", flip_y_transform);
_VariantCall::add_variant_constant(Variant::TRANSFORM3D, "FLIP_Z", flip_z_transform);

Basis identity_basis = Basis();
Basis identity_basis;
Basis flip_x_basis = Basis(-1, 0, 0, 0, 1, 0, 0, 0, 1);
Basis flip_y_basis = Basis(1, 0, 0, 0, -1, 0, 0, 0, 1);
Basis flip_z_basis = Basis(1, 0, 0, 0, 1, 0, 0, 0, -1);
Expand Down
6 changes: 3 additions & 3 deletions drivers/gles3/rasterizer_canvas_gles3.h
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ class RasterizerCanvasGLES3 : public RendererCanvasRender {
uint32_t start = 0;
uint32_t instance_count = 0;

RID tex = RID();
RID tex;
RS::CanvasItemTextureFilter filter = RS::CANVAS_ITEM_TEXTURE_FILTER_MAX;
RS::CanvasItemTextureRepeat repeat = RS::CANVAS_ITEM_TEXTURE_REPEAT_MAX;

Expand All @@ -263,7 +263,7 @@ class RasterizerCanvasGLES3 : public RendererCanvasRender {

Item *clip = nullptr;

RID material = RID();
RID material;
GLES3::CanvasMaterialData *material_data = nullptr;
CanvasShaderGLES3::ShaderVariant shader_variant = CanvasShaderGLES3::MODE_QUAD;

Expand Down Expand Up @@ -303,7 +303,7 @@ class RasterizerCanvasGLES3 : public RendererCanvasRender {

bool using_directional_lights = false;

RID current_tex = RID();
RID current_tex;
RS::CanvasItemTextureFilter current_filter_mode = RS::CANVAS_ITEM_TEXTURE_FILTER_MAX;
RS::CanvasItemTextureRepeat current_repeat_mode = RS::CANVAS_ITEM_TEXTURE_REPEAT_MAX;

Expand Down
12 changes: 6 additions & 6 deletions drivers/gles3/rasterizer_scene_gles3.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@ struct RenderDataGLES3 {
Ref<RenderSceneBuffersGLES3> render_buffers;
bool transparent_bg = false;

Transform3D cam_transform = Transform3D();
Transform3D inv_cam_transform = Transform3D();
Projection cam_projection = Projection();
Transform3D cam_transform;
Transform3D inv_cam_transform;
Projection cam_projection;
bool cam_orthogonal = false;

// For stereo rendering
Expand All @@ -115,9 +115,9 @@ struct RenderDataGLES3 {
const PagedArray<RenderGeometryInstance *> *instances = nullptr;
const PagedArray<RID> *lights = nullptr;
const PagedArray<RID> *reflection_probes = nullptr;
RID environment = RID();
RID camera_attributes = RID();
RID reflection_probe = RID();
RID environment;
RID camera_attributes;
RID reflection_probe;
int reflection_probe_pass = 0;

float lod_distance_multiplier = 0.0;
Expand Down
2 changes: 1 addition & 1 deletion drivers/gles3/storage/texture_storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ struct Texture {
bool is_external = false;
bool is_render_target = false;

RID proxy_to = RID();
RID proxy_to;
Vector<RID> proxies;

String path;
Expand Down
8 changes: 4 additions & 4 deletions editor/action_map_editor.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ class ActionMapEditor : public Control {

public:
struct ActionInfo {
String name = String();
Dictionary action = Dictionary();
String name;
Dictionary action;

Ref<Texture2D> icon = Ref<Texture2D>();
bool editable = true;
Expand All @@ -67,8 +67,8 @@ class ActionMapEditor : public Control {

// Storing which action/event is currently being edited in the InputEventConfigurationDialog.

Dictionary current_action = Dictionary();
String current_action_name = String();
Dictionary current_action;
String current_action_name;
int current_action_event_index = -1;

// Popups
Expand Down
2 changes: 1 addition & 1 deletion editor/debugger/editor_debugger_inspector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ void EditorDebuggerInspector::add_stack_variable(const Array &p_array) {
Variant v = var.value;

PropertyHint h = PROPERTY_HINT_NONE;
String hs = String();
String hs;

if (v.get_type() == Variant::OBJECT) {
v = Object::cast_to<EncodedObjectAsID>(v)->get_object_id();
Expand Down
2 changes: 1 addition & 1 deletion editor/editor_properties.h
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@ class EditorPropertyQuaternion : public EditorProperty {
EditorSpinSlider *euler[3];
Button *edit_button = nullptr;

Vector3 edit_euler = Vector3();
Vector3 edit_euler;

void _value_changed(double p_val, const String &p_name);
void _edit_custom_value();
Expand Down
2 changes: 1 addition & 1 deletion editor/import/resource_importer_scene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ void _rescale_importer_mesh(Vector3 p_scale, Ref<ImporterMesh> p_mesh, bool is_s
const int fmt_compress_flags = p_mesh->get_surface_format(surf_idx);
Array arr = p_mesh->get_surface_arrays(surf_idx);
String name = p_mesh->get_surface_name(surf_idx);
Dictionary lods = Dictionary();
Dictionary lods;
Ref<Material> mat = p_mesh->get_surface_material(surf_idx);
{
Vector<Vector3> vertex_array = arr[ArrayMesh::ARRAY_VERTEX];
Expand Down
2 changes: 1 addition & 1 deletion editor/plugins/animation_player_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -950,7 +950,7 @@ void AnimationPlayerEditor::_update_animation_list_icons() {
}

void AnimationPlayerEditor::_update_name_dialog_library_dropdown() {
StringName current_library_name = StringName();
StringName current_library_name;
if (animation->has_selectable_items()) {
String current_animation_name = animation->get_item_text(animation->get_selected());
Ref<Animation> current_animation = player->get_animation(current_animation_name);
Expand Down
2 changes: 1 addition & 1 deletion editor/plugins/animation_state_machine_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref<InputEv
if (mm.is_valid()) {
state_machine_draw->grab_focus();

String new_over_node = StringName();
String new_over_node;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initializing a String with StringName() was probably not intentional.

int new_over_node_what = -1;
if (tool_select->is_pressed()) {
for (int i = node_rects.size() - 1; i >= 0; i--) { // Inverse to draw order.
Expand Down
16 changes: 8 additions & 8 deletions editor/plugins/canvas_item_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ Point2 CanvasItemEditor::snap_point(Point2 p_target, unsigned int p_modes, unsig

// Other nodes sides
if ((is_snap_active && snap_other_nodes && (p_modes & SNAP_OTHER_NODES)) || (p_forced_modes & SNAP_OTHER_NODES)) {
Transform2D to_snap_transform = Transform2D();
Transform2D to_snap_transform;
List<const CanvasItem *> exceptions = List<const CanvasItem *>();
for (const CanvasItem *E : p_other_nodes_exceptions) {
exceptions.push_back(E);
Expand Down Expand Up @@ -813,7 +813,7 @@ Vector2 CanvasItemEditor::_position_to_anchor(const Control *p_control, Vector2

Rect2 parent_rect = p_control->get_parent_anchorable_rect();

Vector2 output = Vector2();
Vector2 output;
if (p_control->is_layout_rtl()) {
output.x = (parent_rect.size.x == 0) ? 0.0 : (parent_rect.size.x - p_control->get_transform().xform(position).x - parent_rect.position.x) / parent_rect.size.x;
} else {
Expand Down Expand Up @@ -2268,7 +2268,7 @@ bool CanvasItemEditor::_gui_input_select(const Ref<InputEvent> &p_event) {
}
}

String suffix = String();
String suffix;
if (locked == 1) {
suffix = " (" + TTR("Locked") + ")";
} else if (locked == 2) {
Expand Down Expand Up @@ -2790,7 +2790,7 @@ void CanvasItemEditor::_draw_rulers() {
int font_size = get_theme_font_size(SNAME("rulers_size"), SNAME("EditorFonts"));

// The rule transform
Transform2D ruler_transform = Transform2D();
Transform2D ruler_transform;
if (grid_snap_active || _is_grid_visible()) {
List<CanvasItem *> selection = _get_edited_canvas_items();
if (snap_relative && selection.size() > 0) {
Expand All @@ -2816,11 +2816,11 @@ void CanvasItemEditor::_draw_rulers() {

// Subdivisions
int major_subdivision = 2;
Transform2D major_subdivide = Transform2D();
Transform2D major_subdivide;
major_subdivide.scale(Size2(1.0 / major_subdivision, 1.0 / major_subdivision));

int minor_subdivision = 5;
Transform2D minor_subdivide = Transform2D();
Transform2D minor_subdivide;
minor_subdivide.scale(Size2(1.0 / minor_subdivision, 1.0 / minor_subdivision));

// First and last graduations to draw (in the ruler space)
Expand Down Expand Up @@ -3032,7 +3032,7 @@ void CanvasItemEditor::_draw_ruler_tool() {
viewport->draw_string_outline(font, text_pos2, TS->format_number(vformat("%.1f px", length_vector.y)), HORIZONTAL_ALIGNMENT_LEFT, -1, font_size, outline_size, outline_color);
viewport->draw_string(font, text_pos2, TS->format_number(vformat("%.1f px", length_vector.y)), HORIZONTAL_ALIGNMENT_LEFT, -1, font_size, font_secondary_color);

Point2 v_angle_text_pos = Point2();
Point2 v_angle_text_pos;
v_angle_text_pos.x = CLAMP(begin.x - angle_text_width / 2, angle_text_width / 2, viewport->get_rect().size.x - angle_text_width);
v_angle_text_pos.y = begin.y < end.y ? MIN(text_pos2.y - 2 * text_height, begin.y - text_height * 0.5) : MAX(text_pos2.y + text_height * 3, begin.y + text_height * 1.5);
viewport->draw_string_outline(font, v_angle_text_pos, TS->format_number(vformat(String::utf8("%d°"), vertical_angle)), HORIZONTAL_ALIGNMENT_LEFT, -1, font_size, outline_size, outline_color);
Expand All @@ -3043,7 +3043,7 @@ void CanvasItemEditor::_draw_ruler_tool() {
viewport->draw_string_outline(font, text_pos2, TS->format_number(vformat("%.1f px", length_vector.x)), HORIZONTAL_ALIGNMENT_LEFT, -1, font_size, outline_size, outline_color);
viewport->draw_string(font, text_pos2, TS->format_number(vformat("%.1f px", length_vector.x)), HORIZONTAL_ALIGNMENT_LEFT, -1, font_size, font_secondary_color);

Point2 h_angle_text_pos = Point2();
Point2 h_angle_text_pos;
h_angle_text_pos.x = CLAMP(end.x - angle_text_width / 2, angle_text_width / 2, viewport->get_rect().size.x - angle_text_width);
if (begin.y < end.y) {
h_angle_text_pos.y = end.y + text_height * 1.5;
Expand Down
6 changes: 3 additions & 3 deletions editor/plugins/canvas_item_editor_plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -339,12 +339,12 @@ class CanvasItemEditor : public VBoxContainer {

Point2 drag_start_origin;
DragType drag_type = DRAG_NONE;
Point2 drag_from = Vector2();
Point2 drag_to = Vector2();
Point2 drag_from;
Point2 drag_to;
Point2 drag_rotation_center;
List<CanvasItem *> drag_selection;
int dragged_guide_index = -1;
Point2 dragged_guide_pos = Point2();
Point2 dragged_guide_pos;
bool is_hovering_h_guide = false;
bool is_hovering_v_guide = false;

Expand Down
2 changes: 1 addition & 1 deletion editor/plugins/control_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -816,7 +816,7 @@ Vector2 ControlEditorToolbar::_position_to_anchor(const Control *p_control, Vect

Rect2 parent_rect = p_control->get_parent_anchorable_rect();

Vector2 output = Vector2();
Vector2 output;
if (p_control->is_layout_rtl()) {
output.x = (parent_rect.size.x == 0) ? 0.0 : (parent_rect.size.x - p_control->get_transform().xform(position).x - parent_rect.position.x) / parent_rect.size.x;
} else {
Expand Down
2 changes: 1 addition & 1 deletion editor/plugins/material_editor_plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class SubViewportContainer;
class MaterialEditor : public Control {
GDCLASS(MaterialEditor, Control);

Vector2 rot = Vector2();
Vector2 rot;

HBoxContainer *layout_2d = nullptr;
ColorRect *rect_instance = nullptr;
Expand Down
16 changes: 8 additions & 8 deletions editor/plugins/node_3d_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1329,7 +1329,7 @@ void Node3DEditorViewport::_list_select(Ref<InputEventMouseButton> b) {
}
}

String suffix = String();
String suffix;
if (locked == 1) {
suffix = " (" + TTR("Locked") + ")";
} else if (locked == 2) {
Expand Down Expand Up @@ -3492,7 +3492,7 @@ void Node3DEditorViewport::update_transform_gizmo_view() {
}

for (int i = 0; i < 3; i++) {
Transform3D axis_angle = Transform3D();
Transform3D axis_angle;
if (xform.basis.get_column(i).normalized().dot(xform.basis.get_column((i + 1) % 3).normalized()) < 1.0) {
axis_angle = axis_angle.looking_at(xform.basis.get_column(i).normalized(), xform.basis.get_column((i + 1) % 3).normalized());
}
Expand Down Expand Up @@ -6803,8 +6803,8 @@ void Node3DEditor::_init_grid() {

// Don't draw lines over the origin if it's enabled.
if (!(origin_enabled && Math::is_zero_approx(position_a))) {
Vector3 line_bgn = Vector3();
Vector3 line_end = Vector3();
Vector3 line_bgn;
Vector3 line_end;
line_bgn[a] = position_a;
line_end[a] = position_a;
line_bgn[b] = bgn_b;
Expand All @@ -6819,8 +6819,8 @@ void Node3DEditor::_init_grid() {
}

if (!(origin_enabled && Math::is_zero_approx(position_b))) {
Vector3 line_bgn = Vector3();
Vector3 line_end = Vector3();
Vector3 line_bgn;
Vector3 line_end;
line_bgn[b] = position_b;
line_end[b] = position_b;
line_bgn[a] = bgn_a;
Expand Down Expand Up @@ -6988,8 +6988,8 @@ void Node3DEditor::_snap_selected_nodes_to_floor() {
for (Node *E : selection) {
Node3D *sp = Object::cast_to<Node3D>(E);
if (sp) {
Vector3 from = Vector3();
Vector3 position_offset = Vector3();
Vector3 from;
Vector3 position_offset;

// Priorities for snapping to floor are CollisionShapes, VisualInstances and then origin
HashSet<VisualInstance3D *> vi = _get_child_nodes<VisualInstance3D>(sp);
Expand Down
2 changes: 1 addition & 1 deletion editor/plugins/node_3d_editor_plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ class Node3DEditor : public VBoxContainer {
bool grid_enabled = false;
bool grid_init_draw = false;
Camera3D::ProjectionType grid_camera_last_update_perspective = Camera3D::PROJECTION_PERSPECTIVE;
Vector3 grid_camera_last_update_position = Vector3();
Vector3 grid_camera_last_update_position;

Ref<ArrayMesh> move_gizmo[3], move_plane_gizmo[3], rotate_gizmo[4], scale_gizmo[3], scale_plane_gizmo[3], axis_gizmo[3];
Ref<StandardMaterial3D> gizmo_color[3];
Expand Down
4 changes: 2 additions & 2 deletions editor/plugins/skeleton_3d_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1288,15 +1288,15 @@ void Skeleton3DGizmoPlugin::set_subgizmo_transform(const EditorNode3DGizmo *p_gi
ERR_FAIL_COND(!skeleton);

// Prepare for global to local.
Transform3D original_to_local = Transform3D();
Transform3D original_to_local;
int parent_idx = skeleton->get_bone_parent(p_id);
if (parent_idx >= 0) {
original_to_local = original_to_local * skeleton->get_bone_global_pose(parent_idx);
}
Basis to_local = original_to_local.get_basis().inverse();

// Prepare transform.
Transform3D t = Transform3D();
Transform3D t;

// Basis.
t.basis = to_local * p_transform.get_basis();
Expand Down
2 changes: 1 addition & 1 deletion editor/plugins/tiles/tiles_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ void TilesEditorPlugin::_thread() {

TypedArray<Vector2i> used_cells = tile_map->get_used_cells(0);

Rect2 encompassing_rect = Rect2();
Rect2 encompassing_rect;
encompassing_rect.set_position(tile_map->map_to_local(used_cells[0]));
for (int i = 0; i < used_cells.size(); i++) {
Vector2i cell = used_cells[i];
Expand Down
2 changes: 1 addition & 1 deletion editor/plugins/tiles/tiles_editor_plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class TilesEditorPlugin : public EditorPlugin {
// For synchronization.
int atlas_sources_lists_current = 0;
float atlas_view_zoom = 1.0;
Vector2 atlas_view_scroll = Vector2();
Vector2 atlas_view_scroll;

void _tile_map_changed();

Expand Down
2 changes: 1 addition & 1 deletion editor/script_create_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -853,7 +853,7 @@ ScriptLanguage::ScriptTemplate ScriptCreateDialog::_parse_template(const ScriptL
script_template.inherit = p_inherits;
String space_indent = " ";
// Get meta delimiter
String meta_delimiter = String();
String meta_delimiter;
List<String> comment_delimiters;
p_language->get_comment_delimiters(&comment_delimiters);
for (const String &script_delimiter : comment_delimiters) {
Expand Down
2 changes: 1 addition & 1 deletion modules/gdscript/editor/gdscript_highlighter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ Dictionary GDScriptSyntaxHighlighter::_get_line_syntax_highlighting_impl(int p_l
}

String word = str.substr(j, to - j);
Color col = Color();
Color col;
if (global_functions.has(word)) {
// "assert" and "preload" are reserved, so highlight even if not followed by a bracket.
if (word == GDScriptTokenizer::get_token_name(GDScriptTokenizer::Token::ASSERT) || word == GDScriptTokenizer::get_token_name(GDScriptTokenizer::Token::PRELOAD)) {
Expand Down
Loading