mirror of
https://github.com/salsa-rs/salsa.git
synced 2025-02-02 09:46:06 +00:00
remove the _mut
accesors from Table (unused)
This commit is contained in:
parent
f12874fe62
commit
c251001da6
3 changed files with 1 additions and 62 deletions
|
@ -142,10 +142,6 @@ impl Runtime {
|
|||
&self.table
|
||||
}
|
||||
|
||||
pub(crate) fn table_mut(&mut self) -> &mut Table {
|
||||
&mut self.table
|
||||
}
|
||||
|
||||
/// Increments the "current revision" counter and clears
|
||||
/// the cancellation flag.
|
||||
///
|
||||
|
|
48
src/table.rs
48
src/table.rs
|
@ -9,10 +9,7 @@ use crossbeam::atomic::AtomicCell;
|
|||
use memo::MemoTable;
|
||||
use parking_lot::Mutex;
|
||||
|
||||
use crate::{
|
||||
zalsa::{transmute_data_ptr, transmute_data_ptr_mut},
|
||||
Id, IngredientIndex,
|
||||
};
|
||||
use crate::{zalsa::transmute_data_ptr, Id, IngredientIndex, Revision};
|
||||
|
||||
pub(crate) mod memo;
|
||||
|
||||
|
@ -89,17 +86,6 @@ impl Table {
|
|||
page_ref.get(slot)
|
||||
}
|
||||
|
||||
/// Get a mutable reference to the data for `id`, which must have been allocated from this table with type `T`.
|
||||
///
|
||||
/// # Panics
|
||||
///
|
||||
/// If `id` is out of bounds or the does not have the type `T`.
|
||||
pub fn get_mut<T: Slot>(&mut self, id: Id) -> &mut T {
|
||||
let (page, slot) = split_id(id);
|
||||
let page_ref = self.page_mut::<T>(page);
|
||||
page_ref.get_mut(slot)
|
||||
}
|
||||
|
||||
/// Get a raw pointer to the data for `id`, which must have been allocated from this table.
|
||||
///
|
||||
/// # Panics
|
||||
|
@ -124,15 +110,6 @@ impl Table {
|
|||
self.pages[page.0].assert_type::<Page<T>>()
|
||||
}
|
||||
|
||||
/// Gets a mutable reference to the page which has slots of type `T`
|
||||
///
|
||||
/// # Panics
|
||||
///
|
||||
/// If `page` is out of bounds or the type `T` is incorrect.
|
||||
fn page_mut<T: Slot>(&mut self, page: PageIndex) -> &mut Page<T> {
|
||||
self.pages[page.0].assert_type_mut::<Page<T>>()
|
||||
}
|
||||
|
||||
/// Allocate a new page for the given ingredient and with slots of type `T`
|
||||
pub fn push_page<T: Slot>(&self, ingredient: IngredientIndex) -> PageIndex {
|
||||
let page = Box::new(<Page<T>>::new(ingredient));
|
||||
|
@ -178,16 +155,6 @@ impl<T: Slot> Page<T> {
|
|||
unsafe { &*self.data[slot.0].get() }
|
||||
}
|
||||
|
||||
/// Returns a mut reference to the given slot.
|
||||
///
|
||||
/// # Panics
|
||||
///
|
||||
/// If slot is out of bounds
|
||||
pub(crate) fn get_mut(&mut self, slot: SlotIndex) -> &mut T {
|
||||
self.check_bounds(slot);
|
||||
self.data[slot.0].get_mut()
|
||||
}
|
||||
|
||||
/// Returns a raw pointer to the given slot.
|
||||
///
|
||||
/// # Panics
|
||||
|
@ -259,19 +226,6 @@ impl dyn TablePage {
|
|||
// SAFETY: Assertion above
|
||||
unsafe { transmute_data_ptr::<dyn TablePage, T>(self) }
|
||||
}
|
||||
|
||||
fn assert_type_mut<T: Any>(&mut self) -> &mut T {
|
||||
assert_eq!(
|
||||
Any::type_id(self),
|
||||
TypeId::of::<T>(),
|
||||
"page has hidden type `{:?}` but `{:?}` was expected",
|
||||
self.hidden_type_name(),
|
||||
std::any::type_name::<T>(),
|
||||
);
|
||||
|
||||
// SAFETY: Assertion above
|
||||
unsafe { transmute_data_ptr_mut::<dyn TablePage, T>(self) }
|
||||
}
|
||||
}
|
||||
|
||||
fn make_id(page: PageIndex, slot: SlotIndex) -> Id {
|
||||
|
|
11
src/zalsa.rs
11
src/zalsa.rs
|
@ -345,14 +345,3 @@ pub(crate) unsafe fn transmute_data_ptr<T: ?Sized, U>(t: &T) -> &U {
|
|||
let u: *const U = t as *const U;
|
||||
unsafe { &*u }
|
||||
}
|
||||
|
||||
/// Given a wide pointer `T`, extracts the data pointer (typed as `U`).
|
||||
///
|
||||
/// # Safety requirement
|
||||
///
|
||||
/// `U` must be correct type for the data pointer.
|
||||
pub(crate) unsafe fn transmute_data_ptr_mut<T: ?Sized, U>(t: &mut T) -> &mut U {
|
||||
let t: *mut T = t;
|
||||
let u: *mut U = t as *mut U;
|
||||
unsafe { &mut *u }
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue