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 _camelcase_to_underscore (and thus String.capitalize) #100016

Merged

Conversation

Ivorforce
Copy link
Member

…by using a rolling cache of character attributes, instead of re-computing each iteration.

There's definitely some more optimization that could be done here, but this is low hanging fruit.

newplot

New implementation leads to e.g. 1.2x speed improvement for to_camel_case.

…ng a rolling cache of character attributes, instead of re-computing each iteration.
@Ivorforce Ivorforce requested a review from a team as a code owner December 4, 2024 17:41
@Mickeon Mickeon changed the title Optimize _camelcase_to_underscore (and thus String.capitalize) Optimize _camelcase_to_underscore (and thus String.capitalize) Dec 4, 2024
@Mickeon Mickeon added this to the 4.x milestone Dec 4, 2024
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.

Looks good to me! The logic doesn't change, but we save a few operations.

@clayjohn clayjohn modified the milestones: 4.x, 4.4 Dec 5, 2024
@Repiteo Repiteo merged commit 06cce0e into godotengine:master Dec 5, 2024
20 checks passed
@Repiteo
Copy link
Contributor

Repiteo commented Dec 5, 2024

Thanks!

@Ivorforce Ivorforce deleted the camelcase-to-underscore-rolling-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