diff --git a/src/active_query.rs b/src/active_query.rs index 3e0bac0a..87b834ba 100644 --- a/src/active_query.rs +++ b/src/active_query.rs @@ -98,11 +98,11 @@ impl ActiveQuery { self.input_outputs.contains(&(EdgeKind::Output, key)) } - pub(crate) fn revisions(&self) -> QueryRevisions { + pub(crate) fn into_revisions(self) -> QueryRevisions { let input_outputs = if self.input_outputs.is_empty() { EMPTY_DEPENDENCIES.clone() } else { - self.input_outputs.iter().copied().collect() + self.input_outputs.into_iter().collect() }; let edges = QueryEdges::new(input_outputs); @@ -117,7 +117,7 @@ impl ActiveQuery { changed_at: self.changed_at, origin, durability: self.durability, - tracked_struct_ids: self.tracked_struct_ids.clone(), + tracked_struct_ids: self.tracked_struct_ids, } } diff --git a/src/function/execute.rs b/src/function/execute.rs index 15c9f88b..0f1876b6 100644 --- a/src/function/execute.rs +++ b/src/function/execute.rs @@ -84,18 +84,13 @@ where self.diff_outputs(db, database_key_index, old_memo, &revisions); } - let value = self - .insert_memo( - zalsa, - id, - Memo::new(Some(value), revision_now, revisions.clone()), - ) - .unwrap(); - - let stamped_value = revisions.stamped_value(value); - tracing::debug!("{database_key_index:?}: read_upgrade: result.revisions = {revisions:#?}"); - stamped_value + let stamp_template = revisions.stamp_template(); + let value = self + .insert_memo(zalsa, id, Memo::new(Some(value), revision_now, revisions)) + .unwrap(); + + stamp_template.stamp(value) } } diff --git a/src/zalsa_local.rs b/src/zalsa_local.rs index 71c09855..e70cd38f 100644 --- a/src/zalsa_local.rs +++ b/src/zalsa_local.rs @@ -356,6 +356,25 @@ pub(crate) struct QueryRevisions { impl QueryRevisions { pub(crate) fn stamped_value(&self, value: V) -> StampedValue { + self.stamp_template().stamp(value) + } + + pub(crate) fn stamp_template(&self) -> StampTemplate { + StampTemplate { + durability: self.durability, + changed_at: self.changed_at, + } + } +} + +#[derive(Copy, Clone, Debug, Eq, PartialEq)] +pub(crate) struct StampTemplate { + durability: Durability, + changed_at: Revision, +} + +impl StampTemplate { + pub(crate) fn stamp(self, value: V) -> StampedValue { StampedValue { value, durability: self.durability, @@ -516,7 +535,7 @@ impl ActiveQueryGuard<'_> { // If this frame were a cycle participant, it would have unwound. assert!(popped_query.cycle.is_none()); - popped_query.revisions() + popped_query.into_revisions() } /// If the active query is registered as a cycle participant, remove and