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

Optimize String::is_valid_filename() and String::validate_filename() #100015

Merged
merged 1 commit into from
Dec 5, 2024

Conversation

Ivorforce
Copy link
Contributor

@Ivorforce Ivorforce commented Dec 4, 2024

...by caching invalid filename characters, instead of re-splitting each call.

The relevant Godot benchmark reveals is_valid_filename is almost 10x faster, and validate_filename is about 4x faster.

newplot

@Ivorforce Ivorforce requested a review from a team as a code owner December 4, 2024 16:53
…ilename characters, instead of re-splitting each call.
@Ivorforce Ivorforce force-pushed the is-valid-filename-cache branch from 6c01e8e to 0d2e13b Compare December 4, 2024 16:54
Copy link
Member

@clayjohn clayjohn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing. I have never seen a more beautiful graph

@clayjohn clayjohn modified the milestones: 4.x, 4.4 Dec 5, 2024
@adamscott adamscott changed the title Optimize is_valid_filename and validate_filename Optimize String::is_valid_filename() and String::validate_filename() Dec 5, 2024
@Repiteo Repiteo merged commit 3a948ab into godotengine:master Dec 5, 2024
20 checks passed
@Repiteo
Copy link
Contributor

Repiteo commented Dec 5, 2024

Thanks!

@Ivorforce Ivorforce deleted the is-valid-filename-cache branch December 5, 2024 22:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants