From 427a2bacf58e670ee73f585068b93d88b49fed61 Mon Sep 17 00:00:00 2001 From: Wei Liu Date: Sun, 29 Jan 2023 20:45:17 +0000 Subject: [PATCH] block_util: convert aligned_operations to SmallVec The number of aligned operations can not be larger than the number of descriptors. Initializing the capacity to 1 is good enough per the observation that most of time there is only one data descriptor in a given request. Signed-off-by: Wei Liu --- block_util/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/block_util/src/lib.rs b/block_util/src/lib.rs index cfce6d06e..1a1f48c45 100644 --- a/block_util/src/lib.rs +++ b/block_util/src/lib.rs @@ -201,7 +201,7 @@ pub struct Request { pub data_descriptors: SmallVec<[(GuestAddress, u32); 1]>, pub status_addr: GuestAddress, pub writeback: bool, - pub aligned_operations: Vec, + pub aligned_operations: SmallVec<[AlignedOperation; 1]>, pub start: Instant, } @@ -233,7 +233,7 @@ impl Request { data_descriptors: SmallVec::with_capacity(1), status_addr: GuestAddress(0), writeback: true, - aligned_operations: Vec::new(), + aligned_operations: SmallVec::with_capacity(1), start: Instant::now(), };