bytes icon indicating copy to clipboard operation
bytes copied to clipboard

Simplify <Vec<u8> as BufMut>::bytes_mut()

Open danburkert opened this issue 4 years ago • 2 comments

Removes a call to UninitMut indexing, which can panic, from Vec::<u8>::bytes_mut(). I came across this while looking at a performance issue encountered after moving to bytes 0.6. This change makes a microbenchmark in prost slightly faster, although there's still a big delta between 0.5 and 0.6. See danburkert/prost#381.

danburkert avatar Nov 09 '20 08:11 danburkert

Added a second commit which adds an #[inline] for Vec::put_slice, which closed most of the remaining perf difference between 0.5 and 0.6. Will have another PR to add inlines to UninitSlice to close out the rest.

danburkert avatar Nov 09 '20 08:11 danburkert

@danburkert Could you resolve merge conflicts?

taiki-e avatar Apr 10 '21 18:04 taiki-e