tokio-rs / bytes

Utilities for working with bytes
MIT License
1.89k stars 284 forks source link

Tweak clear and truncate length modifications #700

Closed Darksonn closed 5 months ago

Darksonn commented 5 months ago

As mentioned in https://github.com/tokio-rs/bytes/pull/699#pullrequestreview-2021892450.

Also changes truncate to use <=. It is a no-op in that case, but I'm thinking that doing the write in that case would improve branch prediction on this branch. I think that the vast majority of callers will always pass a length that is <= self.len().

cc @paolobarbolini