Performs a single allocation, only when any instances are found, and avoids concatenations and other unnecessary conversions.
(cherry picked from commit cbaec62b0335bc70c7cf7d55651678591bafafd2)
From godotengine/godot#92546
Fixes #861
This is being cherry-picked from godotengine/godot#92546 in order to solve a bug with String::replace which triggers #861 when String::split_float is called because godotengine/godot#95613 changed String::split_float to expect a null terminator which String::replace does not provide on empty returns, (which appears to be a bug) godotengine/godot#97082 had cherry-picked godotengine/godot#92546 without godotengine/godot#95613 or otherwise fixing String::replace's behavior to produce a null terminator character on empty strings. Since it fixes a bug, benefits performance, and shows no signs of breaking unit tests I decided its better to cherry-pick it then try to fix it another way.
Performs a single allocation, only when any instances are found, and avoids concatenations and other unnecessary conversions.
(cherry picked from commit cbaec62b0335bc70c7cf7d55651678591bafafd2)
From godotengine/godot#92546 Fixes #861
This is being cherry-picked from godotengine/godot#92546 in order to solve a bug with
String::replace
which triggers #861 whenString::split_float
is called because godotengine/godot#95613 changedString::split_float
to expect a null terminator whichString::replace
does not provide on empty returns, (which appears to be a bug) godotengine/godot#97082 had cherry-picked godotengine/godot#92546 without godotengine/godot#95613 or otherwise fixingString::replace
's behavior to produce a null terminator character on empty strings. Since it fixes a bug, benefits performance, and shows no signs of breaking unit tests I decided its better to cherry-pick it then try to fix it another way.