mirror of
https://github.com/salsa-rs/salsa.git
synced 2025-02-09 05:38:15 +00:00
Merge pull request #567 from MichaReiser/reduce-set-cloning
Some checks failed
Book / Book (push) Has been cancelled
Test / Test (false, beta) (push) Has been cancelled
Test / Test (false, stable) (push) Has been cancelled
Test / Test (true, nightly) (push) Has been cancelled
Test / Miri (push) Has been cancelled
Test / Benchmarks (push) Has been cancelled
Book / Deploy (push) Has been cancelled
Some checks failed
Book / Book (push) Has been cancelled
Test / Test (false, beta) (push) Has been cancelled
Test / Test (false, stable) (push) Has been cancelled
Test / Test (true, nightly) (push) Has been cancelled
Test / Miri (push) Has been cancelled
Test / Benchmarks (push) Has been cancelled
Book / Deploy (push) Has been cancelled
Reduce cloning of sets in `ActiveQuery` and `QueryRevisions`
This commit is contained in:
commit
884a30cf9d
3 changed files with 29 additions and 15 deletions
|
@ -98,11 +98,11 @@ impl ActiveQuery {
|
||||||
self.input_outputs.contains(&(EdgeKind::Output, key))
|
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() {
|
let input_outputs = if self.input_outputs.is_empty() {
|
||||||
EMPTY_DEPENDENCIES.clone()
|
EMPTY_DEPENDENCIES.clone()
|
||||||
} else {
|
} else {
|
||||||
self.input_outputs.iter().copied().collect()
|
self.input_outputs.into_iter().collect()
|
||||||
};
|
};
|
||||||
|
|
||||||
let edges = QueryEdges::new(input_outputs);
|
let edges = QueryEdges::new(input_outputs);
|
||||||
|
@ -117,7 +117,7 @@ impl ActiveQuery {
|
||||||
changed_at: self.changed_at,
|
changed_at: self.changed_at,
|
||||||
origin,
|
origin,
|
||||||
durability: self.durability,
|
durability: self.durability,
|
||||||
tracked_struct_ids: self.tracked_struct_ids.clone(),
|
tracked_struct_ids: self.tracked_struct_ids,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -84,18 +84,13 @@ where
|
||||||
self.diff_outputs(db, database_key_index, old_memo, &revisions);
|
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:#?}");
|
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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -356,6 +356,25 @@ pub(crate) struct QueryRevisions {
|
||||||
|
|
||||||
impl QueryRevisions {
|
impl QueryRevisions {
|
||||||
pub(crate) fn stamped_value<V>(&self, value: V) -> StampedValue<V> {
|
pub(crate) fn stamped_value<V>(&self, value: V) -> StampedValue<V> {
|
||||||
|
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<V>(self, value: V) -> StampedValue<V> {
|
||||||
StampedValue {
|
StampedValue {
|
||||||
value,
|
value,
|
||||||
durability: self.durability,
|
durability: self.durability,
|
||||||
|
@ -516,7 +535,7 @@ impl ActiveQueryGuard<'_> {
|
||||||
// If this frame were a cycle participant, it would have unwound.
|
// If this frame were a cycle participant, it would have unwound.
|
||||||
assert!(popped_query.cycle.is_none());
|
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
|
/// If the active query is registered as a cycle participant, remove and
|
||||||
|
|
Loading…
Reference in a new issue