Currently when converting from a String to a CompactString using From<String> (also for Box<str>) we wouldn't inline short strings, this was to avoid needing to de-allocate the original String. After some feedback collected in #227 we realized while this was performant, it's not what most users expect to happen.
This PR updates the implementation of From<String> and From<Box<str>> to inline short strings, and it adds a new API CompactStr::from_string_buffer, which retains the current behavior of always re-using the underlying buffer. Note, in #254 we implemented inline-ing during Clone, so even if you use from_string_buffer, future short strings should get inlined.
Currently when converting from a
String
to aCompactString
usingFrom<String>
(also forBox<str>
) we wouldn't inline short strings, this was to avoid needing to de-allocate the originalString
. After some feedback collected in #227 we realized while this was performant, it's not what most users expect to happen.This PR updates the implementation of
From<String>
andFrom<Box<str>>
to inline short strings, and it adds a new APICompactStr::from_string_buffer
, which retains the current behavior of always re-using the underlying buffer. Note, in #254 we implemented inline-ing duringClone
, so even if you usefrom_string_buffer
, future short strings should get inlined.Fixes #227