diff --git a/components/salsa-macro-rules/src/setup_input_struct.rs b/components/salsa-macro-rules/src/setup_input_struct.rs index a0624408c..663ddb465 100644 --- a/components/salsa-macro-rules/src/setup_input_struct.rs +++ b/components/salsa-macro-rules/src/setup_input_struct.rs @@ -83,7 +83,7 @@ macro_rules! setup_input_struct { type Fields = ($($field_ty,)*); /// A array of [`StampedValue<()>`](`StampedValue`) tuples, one per each of the value fields. - type Stamps = $zalsa::Array<$zalsa::Stamp, $N>; + type Stamps = [$zalsa::Stamp; $N]; } impl $Configuration { @@ -284,10 +284,8 @@ macro_rules! setup_input_struct { } } - pub(super) fn builder_into_inner(builder: $Builder, revision: $zalsa::Revision) -> (($($field_ty,)*), $zalsa::Array<$zalsa::Stamp, $N>) { - let stamps = $zalsa::Array::new([ - $($zalsa::stamp(revision, builder.durabilities[$field_index])),* - ]); + pub(super) fn builder_into_inner(builder: $Builder, revision: $zalsa::Revision) -> (($($field_ty,)*), [$zalsa::Stamp; $N]) { + let stamps = [$($zalsa::stamp(revision, builder.durabilities[$field_index])),*]; (builder.fields, stamps) } diff --git a/components/salsa-macro-rules/src/setup_tracked_struct.rs b/components/salsa-macro-rules/src/setup_tracked_struct.rs index d986c6325..622230bea 100644 --- a/components/salsa-macro-rules/src/setup_tracked_struct.rs +++ b/components/salsa-macro-rules/src/setup_tracked_struct.rs @@ -121,7 +121,7 @@ macro_rules! setup_tracked_struct { type Fields<$db_lt> = ($($field_ty,)*); - type Revisions = $zalsa::Array<$Revision, $N>; + type Revisions = [$Revision; $N]; type Struct<$db_lt> = $Struct<$db_lt>; @@ -138,7 +138,7 @@ macro_rules! setup_tracked_struct { } fn new_revisions(current_revision: $Revision) -> Self::Revisions { - $zalsa::Array::new([current_revision; $N]) + [current_revision; $N] } unsafe fn update_fields<$db_lt>( diff --git a/src/array.rs b/src/array.rs deleted file mode 100644 index ef82d9dd6..000000000 --- a/src/array.rs +++ /dev/null @@ -1,27 +0,0 @@ -use std::fmt::Debug; -use std::ops::{Deref, DerefMut}; - -#[derive(Copy, Clone, Debug)] -pub struct Array { - data: [T; N], -} - -impl Array { - pub fn new(data: [T; N]) -> Self { - Self { data } - } -} - -impl Deref for Array { - type Target = [T]; - - fn deref(&self) -> &Self::Target { - &self.data - } -} - -impl DerefMut for Array { - fn deref_mut(&mut self) -> &mut Self::Target { - &mut self.data - } -} diff --git a/src/input.rs b/src/input.rs index 0cac51655..529cb230e 100644 --- a/src/input.rs +++ b/src/input.rs @@ -1,6 +1,6 @@ use std::any::{Any, TypeId}; use std::fmt; -use std::ops::DerefMut; +use std::ops::IndexMut; use std::sync::Arc; pub mod input_field; @@ -34,7 +34,7 @@ pub trait Configuration: Any { type Fields: Send + Sync; /// A array of [`StampedValue<()>`](`StampedValue`) tuples, one per each of the value fields. - type Stamps: Send + Sync + fmt::Debug + DerefMut; + type Stamps: Send + Sync + fmt::Debug + IndexMut; } pub struct JarImpl { diff --git a/src/lib.rs b/src/lib.rs index d69c59c17..1dd2b9769 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -3,7 +3,6 @@ mod accumulator; mod active_query; -mod array; mod attach; mod cancelled; mod cycle; @@ -50,7 +49,7 @@ pub use self::input::setter::Setter; pub use self::key::DatabaseKeyIndex; pub use self::revision::Revision; pub use self::runtime::Runtime; -pub use self::storage::Storage; +pub use self::storage::{Storage, StorageHandle}; pub use self::update::Update; pub use self::zalsa::IngredientIndex; pub use crate::attach::with_attached_database; @@ -77,7 +76,6 @@ pub mod plumbing { }; pub use crate::accumulator::Accumulator; - pub use crate::array::Array; pub use crate::attach::{attach, with_attached_database}; pub use crate::cycle::{CycleRecoveryAction, CycleRecoveryStrategy}; pub use crate::database::{current_revision, Database}; diff --git a/src/tracked_struct.rs b/src/tracked_struct.rs index 65e9862a1..cbb6ab8ee 100644 --- a/src/tracked_struct.rs +++ b/src/tracked_struct.rs @@ -4,7 +4,7 @@ use std::any::TypeId; use std::fmt; use std::hash::Hash; use std::marker::PhantomData; -use std::ops::DerefMut; +use std::ops::Index; use std::sync::Arc; use crossbeam_queue::SegQueue; @@ -45,7 +45,7 @@ pub trait Configuration: Sized + 'static { /// When a struct is re-recreated in a new revision, the corresponding /// entries for each field are updated to the new revision if their /// values have changed (or if the field is marked as `#[no_eq]`). - type Revisions: Send + Sync + DerefMut; + type Revisions: Send + Sync + Index; type Struct<'db>: Copy; @@ -151,7 +151,7 @@ pub trait TrackedStructInDb: SalsaStructInDb { /// /// This ingredient only stores the "id" fields. It is a kind of "dressed up" interner; /// the active query + values of id fields are hashed to create the tracked -/// struct id. The value fields are stored in [`crate::function::FunctionIngredient`] +/// struct id. The value fields are stored in [`crate::function::IngredientImpl`] /// instances keyed by the tracked struct id. Unlike normal interners, tracked /// struct indices can be deleted and reused aggressively: when a tracked /// function re-executes, any tracked structs that it created before but did @@ -676,11 +676,6 @@ where /// /// Note that this function returns the entire tuple of value fields. /// The caller is responsible for selecting the appropriate element. - /// - /// This function takes two indices: - /// - `field_index` is the absolute index of the field on the tracked struct. - /// - `relative_tracked_index` is the index of the field relative only to other - /// tracked fields. pub fn tracked_field<'db>( &'db self, db: &'db dyn crate::Database, diff --git a/src/tracked_struct/tracked_field.rs b/src/tracked_struct/tracked_field.rs index 8c09cbefa..8224776fb 100644 --- a/src/tracked_struct/tracked_field.rs +++ b/src/tracked_struct/tracked_field.rs @@ -12,7 +12,7 @@ use crate::{Database, Id}; /// This ingredient only stores the "id" fields. /// It is a kind of "dressed up" interner; /// the active query + values of id fields are hashed to create the tracked struct id. -/// The value fields are stored in [`crate::function::FunctionIngredient`] instances keyed by the tracked struct id. +/// The value fields are stored in [`crate::function::IngredientImpl`] instances keyed by the tracked struct id. /// Unlike normal interners, tracked struct indices can be deleted and reused aggressively: /// when a tracked function re-executes, /// any tracked structs that it created before but did not create this time can be deleted. @@ -23,7 +23,7 @@ where /// Index of this ingredient in the database (used to construct database-ids, etc). ingredient_index: IngredientIndex, - /// The absolute index of this field on the tracked struct. + /// The index of this field on the tracked struct relative to all other tracked fields. field_index: usize, phantom: PhantomData Value>, }