We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 33ea848 commit 76b19e6Copy full SHA for 76b19e6
http-body-util/src/util.rs
@@ -82,9 +82,15 @@ impl<T: Buf> Buf for BufList<T> {
82
}
83
Some(front) if front.remaining() > len => front.copy_to_bytes(len),
84
_ => {
85
- assert!(len <= self.remaining(), "`len` greater than remaining");
+ let rem = self.remaining();
86
+ assert!(len <= rem, "`len` greater than remaining");
87
let mut bm = BytesMut::with_capacity(len);
- bm.put(self.take(len));
88
+ if rem == len {
89
+ // .take() costs a lot more, so skip it if we don't need it
90
+ bm.put(self);
91
+ } else {
92
+ bm.put(self.take(len));
93
+ }
94
bm.freeze()
95
96
0 commit comments