You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
The generalized structure of Pool uses the
ToOwned
trait to store it'sT
's internally.For
str
this leads to the usage ofString
as internal data type for the underlyingVec<_>
.This is inferior to
Box<str>
which requires less memory thanString
since it is missing thecapacity
field which makes it approximately 33% smaller thanString
.So in theory using
Box<str>
instead ofString
should result in faster access times due to less cache-trashing.This can be addressed by specializing
Pool
forstr
to storeBox<str>
instead ofString
.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 whileString
orBox<str>
should move them.The text was updated successfully, but these errors were encountered: