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

Exploit Rust's str representation to allow 16 inline bytes for EcoString #44

Open
cactusdualcore opened this issue Dec 8, 2024 · 1 comment

Comments

@cactusdualcore
Copy link

The compact_string crate manages to store a string with length 24 inline by using that all strings in Rust are UTF8 encoded.

This isn't really an important thing to do, because most applications will either have strings with a length much greater than 16 or much less than 15. Just wanted to point out that it's possible.

@laurmaedje
Copy link
Member

I don't think it works for ecow because we already use a full bit of the last byte to distinguish heap vs inline. CompactStr, having 24 bytes rather than 16 bytes, always has a single byte value rather than half of a byte's range for the heap case.

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

No branches or pull requests

2 participants