[4.3] Optimize String::replace
methods
#866
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Performs a single allocation, only when any instances are found, and avoids concatenations and other unnecessary conversions.
(cherry picked from commit cbaec62)
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.