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

Small optimizations #302

Merged
merged 2 commits into from
Sep 1, 2024
Merged

Small optimizations #302

merged 2 commits into from
Sep 1, 2024

Conversation

UkoeHB
Copy link
Contributor

@UkoeHB UkoeHB commented Aug 31, 2024

  • Use SmolStr instead of String in FamilyOwned. Families are almost always <= 23 bytes. Note that SmolStr is no-std when default features are off.
  • Add AttrsList::spans_iter to avoid an unnecessary allocation in Buffer::append.

@@ -21,6 +21,7 @@ rangemap = "1.4.0"
rustc-hash = { version = "1.1.0", default-features = false }
rustybuzz = { version = "0.14", default-features = false, features = ["libm"] }
self_cell = "1.0.1"
smol_str = { version = "0.2.2", default-features = false }
Copy link
Contributor

@grovesNL grovesNL Aug 31, 2024

Choose a reason for hiding this comment

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

For what it's worth, smol_str doesn't seem to be recommended anymore (see the comment by the original author in https://www.reddit.com/r/rust/comments/117ksvr/comment/j9eh35d/)

There's also a comparison of small string crates at https://github.com/rosetta-rs/string-rosetta-rs?tab=readme-ov-file (smol_str was removed from the table in favor of ecow)

Copy link
Contributor Author

@UkoeHB UkoeHB Aug 31, 2024

Choose a reason for hiding this comment

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

I'm not necessarily against it but consider:

  • smol_str has much more adoption, so it's less likely to increase the dependency footprint of users (e.g. bevy uses smol_str).
  • smol_str offers 23 inline bytes vs only 15 in ecow, and the use-case here really doesn't want to allocate.

@jackpot51 jackpot51 merged commit c751217 into pop-os:main Sep 1, 2024
1 of 2 checks passed
@UkoeHB UkoeHB deleted the smolstr branch September 1, 2024 18:55
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.

3 participants