fitzgen / bumpalo

A fast bump allocation arena for Rust
https://docs.rs/bumpalo
Apache License 2.0
1.41k stars 111 forks source link

Improve performance of `String::from_str_in` #231

Closed overlookmotel closed 7 months ago

overlookmotel commented 7 months ago

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 commented 7 months ago

CI should pass if rebased on top of #232.

overlookmotel commented 7 months ago

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 commented 7 months ago

Thanks!