Skip to content

Commit b5591bf

Browse files
committed
change AsSpan to use a range from "from" to "end"
the current code assumes that float.Parse behaves the same as the internal C++ code, however without using "end" as part of the span, it will parse from index 0 to the end of the string, ignoring commas. for example, this causes it to parse "0,5,0" with divisor "," as [50, 50, 0], as the float.Parse method ignores commas in floats. if another divisor is used, it throws a System.FormatException due to containing invalid characters, as it fails to account for the position of the divisor for the span.
1 parent 68410ac commit b5591bf

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

modules/mono/glue/GodotSharp/GodotSharp/Core/StringExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1539,7 +1539,7 @@ public static float[] SplitFloats(this string instance, string divisor, bool all
15391539
if (end < 0)
15401540
end = len;
15411541
if (allowEmpty || end > from)
1542-
ret.Add(float.Parse(instance.AsSpan(from), CultureInfo.InvariantCulture));
1542+
ret.Add(float.Parse(instance.AsSpan(from, end - from), CultureInfo.InvariantCulture));
15431543
if (end == len)
15441544
break;
15451545

0 commit comments

Comments
 (0)