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

Some slightly performance & style updates #370

Merged
merged 4 commits into from
Dec 29, 2024

Conversation

yhx-12243
Copy link
Contributor

  • In the function fn as_bytes in impl CompactString, there is an redundant slicing (with a self.len() call) which is unnecessary after the update c95edd5.
  • This crate has documented that for 64-bit architectures the capacity will be always inlined. So the logic of is_heap can be replaced with directly returning false to reduce some code generation.

@yhx-12243
Copy link
Contributor Author

yhx-12243 commented Mar 10, 2024

It seems that the test needs to be changed, because it's probably that the compiler optimized out the whole test and did not allocate memory at all.

See https://rust.godbolt.org/z/qc349PrGv for a shorter analogue.

@yhx-12243
Copy link
Contributor Author

May be we should wrap this test in a something like core::hint::black_box, or maybe do other things to make sure the compiler will not optimize out the "unused" allocation of long string.

@yhx-12243
Copy link
Contributor Author

Hello @ParkMyCar , do you have time to review this PR if you're spared?

@ParkMyCar
Copy link
Owner

Geez @yhx-12243 this sat for so long, I'm sorry about that! Thanks for the PR and the performance improvements, they look good to me!

@ParkMyCar ParkMyCar merged commit c9f31cd into ParkMyCar:main Dec 29, 2024
27 checks passed
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