Skip to content

Commit

Permalink
chore: refine lifetime for rotate_last_mut (#6193)
Browse files Browse the repository at this point in the history
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
  • Loading branch information
MrCroxx and mergify[bot] committed Nov 3, 2022
1 parent db6691b commit 3c1bac6
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/storage/src/hummock/file_cache/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ where
}

#[allow(clippy::uninit_vec)]
pub fn append(&mut self, key: K, value: &V) {
pub fn append<'b>(&'b mut self, key: K, value: &V) {
let offset = self.data_len;
let len = value.encoded_len();
let bloc = BlockLoc {
Expand All @@ -99,15 +99,12 @@ where
};
self.blocs.push(bloc);

let rotate_last_mut = |buffers: &mut Vec<_>| {
let rotate_last_mut = |buffers: &'b mut Vec<_>| {
buffers.push(DioBuffer::with_capacity_in(
self.buffer_capacity,
&DIO_BUFFER_ALLOCATOR,
));
unsafe {
// TODO: fix this
&mut *(buffers.last_mut().unwrap() as *mut _)
}
buffers.last_mut().unwrap()
};

let buffer = match self.buffers.last_mut() {
Expand Down

0 comments on commit 3c1bac6

Please sign in to comment.