compact_str
compact_str copied to clipboard
Improve efficiency of `is_empty`
is_empty
checks both inline length and heap length:
https://github.com/ParkMyCar/compact_str/blob/302c595d41373943dc432be2381b8f6a74f0ddf6/compact_str/src/repr/mod.rs#L445-L453
I believe an empty string is always stored inline. Therefore it could be reduced to:
pub fn is_empty(&self) -> bool {
self.last_byte() == LastUtf8Char::L0 as u8
}
If my assumption is correct, let me know and I'll make a PR.