mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-06 21:33:14 +00:00
perf(read): Remove unecessary allocation in read_xl_meta_no_data (#1846)
Co-authored-by: houseme <housemecn@gmail.com> Co-authored-by: loverustfs <hello@rustfs.com>
This commit is contained in:
@@ -2712,7 +2712,8 @@ pub async fn read_xl_meta_no_data<R: AsyncRead + Unpin>(reader: &mut R, size: us
|
||||
|
||||
if minor < 2 {
|
||||
read_more(reader, &mut buf, size, want, has_full).await?;
|
||||
return Ok(buf[..want].to_vec());
|
||||
buf.truncate(want);
|
||||
return Ok(buf);
|
||||
}
|
||||
|
||||
let want_max = usize::min(want + MSGP_UINT32_SIZE, size);
|
||||
@@ -2728,7 +2729,8 @@ pub async fn read_xl_meta_no_data<R: AsyncRead + Unpin>(reader: &mut R, size: us
|
||||
|
||||
want += tmp.len() - other_size;
|
||||
|
||||
Ok(buf[..want].to_vec())
|
||||
buf.truncate(want);
|
||||
Ok(buf)
|
||||
}
|
||||
_ => Err(Error::other(std::io::Error::new(
|
||||
std::io::ErrorKind::InvalidData,
|
||||
|
||||
Reference in New Issue
Block a user