From e9da0dfd30ec446c35a1db1c12068c53ce17294c Mon Sep 17 00:00:00 2001 From: Joyless <65855333+Joy-less@users.noreply.github.com> Date: Tue, 29 Apr 2025 23:57:26 +0100 Subject: [PATCH] Don't create unnecessary arrays in C# --- modules/mono/glue/GodotSharp/GodotSharp/Core/Aabb.cs | 6 +++--- modules/mono/glue/GodotSharp/GodotSharp/Core/Mathf.cs | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Aabb.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Aabb.cs index ef550eab0d4..681ab6022ff 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Aabb.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Aabb.cs @@ -479,8 +479,8 @@ namespace Godot /// public readonly bool IntersectsPlane(Plane plane) { - Vector3[] points = - { + ReadOnlySpan points = + [ new Vector3(_position.X, _position.Y, _position.Z), new Vector3(_position.X, _position.Y, _position.Z + _size.Z), new Vector3(_position.X, _position.Y + _size.Y, _position.Z), @@ -489,7 +489,7 @@ namespace Godot new Vector3(_position.X + _size.X, _position.Y, _position.Z + _size.Z), new Vector3(_position.X + _size.X, _position.Y + _size.Y, _position.Z), new Vector3(_position.X + _size.X, _position.Y + _size.Y, _position.Z + _size.Z) - }; + ]; bool over = false; bool under = false; diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Mathf.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Mathf.cs index 16d4616fcd4..228dc55b27d 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Mathf.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Mathf.cs @@ -1665,8 +1665,8 @@ namespace Godot /// The position of the first non-zero digit. public static int StepDecimals(double step) { - double[] sd = new double[] - { + ReadOnlySpan sd = + [ 0.9999, 0.09999, 0.009999, @@ -1676,7 +1676,7 @@ namespace Godot 0.0000009999, 0.00000009999, 0.000000009999, - }; + ]; double abs = Math.Abs(step); double decs = abs - (int)abs; // Strip away integer part for (int i = 0; i < sd.Length; i++)