tokio-rs / bytes

Utilities for working with bytes
MIT License
1.86k stars 278 forks source link

Remove redundant reserve call #674

Closed braddunbar closed 6 months ago

braddunbar commented 6 months ago

Note: Miri is currently failing in CI, but is fixed by https://github.com/tokio-rs/bytes/pull/673

We're calling reserve twice because put_u8 already calls it.

  1. put_u8 calls put_slice
  2. BytesMut::put_slice calls BytesMut::extend_from_slice
  3. BytesMut::extend_from_slice immediately calls reserve
braddunbar commented 6 months ago

Updated with #673 to fix miri tests!

braddunbar commented 6 months ago

@Darksonn Sure thing! Added in 76dae7b880c52384d6a3edb364f1375b45a9274f. I think the following test technically covers it via Extend<&'a u8>, but I like being explicit.