-
Notifications
You must be signed in to change notification settings - Fork 4
Description
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.