From 1325c765255ad483c24b2e47207021d400a766fd Mon Sep 17 00:00:00 2001 From: Wei Liu Date: Sun, 29 Jan 2023 20:38:51 +0000 Subject: [PATCH] block_util: use SmallVec in async adaptor Also fix a comment while at it. Signed-off-by: Wei Liu --- block_util/src/lib.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/block_util/src/lib.rs b/block_util/src/lib.rs index 02da5e49b..cfce6d06e 100644 --- a/block_util/src/lib.rs +++ b/block_util/src/lib.rs @@ -602,7 +602,7 @@ where completion_list: &mut VecDeque<(u64, i32)>, ) -> AsyncIoResult<()> { // Convert libc::iovec into IoSliceMut - let mut slices = Vec::new(); + let mut slices: SmallVec<[IoSliceMut; 1]> = SmallVec::with_capacity(iovecs.len()); for iovec in iovecs.iter() { // SAFETY: on Linux IoSliceMut wraps around libc::iovec slices.push(IoSliceMut::new(unsafe { std::mem::transmute(*iovec) })); @@ -635,9 +635,9 @@ where completion_list: &mut VecDeque<(u64, i32)>, ) -> AsyncIoResult<()> { // Convert libc::iovec into IoSlice - let mut slices = Vec::new(); + let mut slices: SmallVec<[IoSlice; 1]> = SmallVec::with_capacity(iovecs.len()); for iovec in iovecs.iter() { - // SAFETY: on Linux IoSliceMut wraps around libc::iovec + // SAFETY: on Linux IoSlice wraps around libc::iovec slices.push(IoSlice::new(unsafe { std::mem::transmute(*iovec) })); }