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

Improve safety comments on function/fetch #642

Merged
merged 1 commit into from
Jan 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions src/function/fetch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,9 @@ where
if memo.value.is_some()
&& self.shallow_verify_memo(db, zalsa, self.database_key_index(id), memo)
{
// Unsafety invariant: memo is present in memo_map
unsafe {
return Some(self.extend_memo_lifetime(memo));
}
// Unsafety invariant: memo is present in memo_map and we have verified that it is
// still valid for the current revision.
return unsafe { Some(self.extend_memo_lifetime(memo)) };
}
}
None
Expand All @@ -81,10 +80,9 @@ where
let opt_old_memo = self.get_memo_from_table_for(zalsa, id);
if let Some(old_memo) = &opt_old_memo {
if old_memo.value.is_some() && self.deep_verify_memo(db, old_memo, &active_query) {
// Unsafety invariant: memo is present in memo_map.
unsafe {
return Some(self.extend_memo_lifetime(old_memo));
}
// Unsafety invariant: memo is present in memo_map and we have verified that it is
// still valid for the current revision.
return unsafe { Some(self.extend_memo_lifetime(old_memo)) };
}
}

Expand Down
21 changes: 0 additions & 21 deletions src/function/input_outputs.rs
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file is dangling, it seems to have been split across input.rs and accumulated.rs

This file was deleted.

2 changes: 1 addition & 1 deletion src/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ impl dyn TablePage {
fn make_id(page: PageIndex, slot: SlotIndex) -> Id {
let page = page.0 as u32;
let slot = slot.0 as u32;
Id::from_u32(page << PAGE_LEN_BITS | slot)
Id::from_u32((page << PAGE_LEN_BITS) | slot)
}

fn split_id(id: Id) -> (PageIndex, SlotIndex) {
Expand Down
Loading