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

[4.3] Optimize String::replace methods #866

Merged
merged 1 commit into from
Nov 16, 2024

Conversation

Spartan322
Copy link
Member

@Spartan322 Spartan322 commented Nov 16, 2024

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 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 cbaec62)
@Spartan322 Spartan322 changed the title [Core] Optimize String::replace methods [4.3] Optimize String::replace methods Nov 16, 2024
@Spartan322 Spartan322 linked an issue Nov 16, 2024 that may be closed by this pull request
@Spartan322 Spartan322 merged commit f66b3b2 into Redot-Engine:4.3 Nov 16, 2024
18 checks passed
@Spartan322 Spartan322 deleted the 4.3-faster-replace branch November 16, 2024 12:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

[4.3] Redot crashes when you right-click on Color() inside a script
3 participants