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

Specialize Pool for str to use Box<str> internally instead of String #1

Open
Robbepop opened this issue Feb 6, 2017 · 0 comments
Open

Comments

@Robbepop
Copy link

Robbepop commented Feb 6, 2017

The generalized structure of Pool uses the ToOwned trait to store it's T's internally.
For str this leads to the usage of String as internal data type for the underlying Vec<_>.
This is inferior to Box<str> which requires less memory than String since it is missing the capacity field which makes it approximately 33% smaller than String.
So in theory using Box<str> instead of String should result in faster access times due to less cache-trashing.

This can be addressed by specializing Pool for str to store Box<str> instead of String.
The drawbacks are that specialization is currently a nightly feature, however it should be possible to implement this specialization as op-in for depencendies that are okay with nightly versions of the compiler.

Also there should be trait impls for the different kinds of String types within rust.
So interning a &str should copy the contents while String or Box<str> should move them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants