Optimize the latency of lmbench-select-file

This commit is contained in:
Jianfeng Jiang
2024-08-15 03:44:30 +00:00
committed by Tate, Hongliang Tian
parent 5b5f9cffd1
commit 0291b5dc6b
5 changed files with 21 additions and 14 deletions

View File

@ -49,10 +49,7 @@ impl<T> SlotVec<T> {
///
/// Return `None` if `idx` is out of bounds or the item is not exist.
pub fn get(&self, idx: usize) -> Option<&T> {
if idx >= self.slots.len() {
return None;
}
self.slots[idx].as_ref()
self.slots.get(idx)?.as_ref()
}
/// Put an item into the vector.