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

Improve performance of String::from_str_in #231

Merged
merged 2 commits into from
Feb 14, 2024

Conversation

overlookmotel
Copy link
Contributor

@overlookmotel overlookmotel commented Feb 13, 2024

I investigated performance of String::from_str_in. Turns out that even after String::push_str is optimized (#229), the compiler does not figure out that bounds checks and various calculations can be elided.

So this change makes from_str_in about 18% faster for small strings.

PR includes a benchmark to demonstrate this.

Built on top of #229. If you're willing to merge, please merge that one first.

Sorry for sudden barrage of issues and PRs!

@overlookmotel
Copy link
Contributor Author

CI should pass if rebased on top of #232.

Copy link
Owner

@fitzgen fitzgen 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, will merge after the other PR lands. This one probably needs to be rebased as well.

@overlookmotel
Copy link
Contributor Author

overlookmotel commented Feb 14, 2024

Rebased on top of #229 (which is now rebased on top of main). Have done it that way as otherwise there's merge conflicts. Hope that's OK.

@fitzgen fitzgen merged commit 7b3fd17 into fitzgen:main Feb 14, 2024
8 checks passed
@fitzgen
Copy link
Owner

fitzgen commented Feb 14, 2024

Thanks!

@overlookmotel overlookmotel deleted the faster-from-str-in branch February 14, 2024 18:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants