Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: refine lifetime for rotate_last_mut #6193

Merged
merged 2 commits into from
Nov 3, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 @@ -86,7 +86,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 @@ -95,15 +95,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