mirror of
https://github.com/salsa-rs/salsa.git
synced 2025-01-12 08:30:51 +00:00
Improve safety comments on function/fetch
This commit is contained in:
parent
88a1d7774d
commit
63c367b487
3 changed files with 7 additions and 30 deletions
|
@ -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
|
||||
|
@ -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)) };
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,21 +0,0 @@
|
|||
use crate::{
|
||||
accumulator::accumulated_map::AccumulatedMap, zalsa::Zalsa, zalsa_local::QueryOrigin, Id,
|
||||
};
|
||||
|
||||
use super::{Configuration, IngredientImpl};
|
||||
|
||||
impl<C> IngredientImpl<C>
|
||||
where
|
||||
C: Configuration,
|
||||
{
|
||||
pub(super) fn origin(&self, zalsa: &Zalsa, key: Id) -> Option<QueryOrigin> {
|
||||
self.get_memo_from_table_for(zalsa, key)
|
||||
.map(|m| m.revisions.origin.clone())
|
||||
}
|
||||
|
||||
pub(super) fn accumulated(&self, zalsa: &Zalsa, key: Id) -> Option<&AccumulatedMap> {
|
||||
// NEXT STEP: stash and refactor `fetch` to return an `&Memo` so we can make this work
|
||||
self.get_memo_from_table_for(zalsa, key)
|
||||
.map(|m| &m.revisions.accumulated)
|
||||
}
|
||||
}
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue