Win from avoiding some allocation
This commit is contained in:
parent
17707b8421
commit
18b9cb5df4
|
@ -36,7 +36,7 @@ impl IOList {
|
||||||
pub fn write_all(&mut self, cow: Cow<'_, [u8]>) {
|
pub fn write_all(&mut self, cow: Cow<'_, [u8]>) {
|
||||||
self.len += cow.len();
|
self.len += cow.len();
|
||||||
match cow {
|
match cow {
|
||||||
Cow::Borrowed(bs) => self.chunks.push(bs.to_owned()),
|
Cow::Borrowed(bs) => self.rightmost_chunk().extend_from_slice(bs),
|
||||||
Cow::Owned(bs) => self.chunks.push(bs),
|
Cow::Owned(bs) => self.chunks.push(bs),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue