Revert "track outputs for the active record"

This reverts commit de2fb22a1c.
This commit is contained in:
Niko Matsakis 2022-08-12 14:28:30 -04:00
parent 8fc38fed48
commit 15ec60613c
2 changed files with 9 additions and 20 deletions

View file

@ -1,5 +1,3 @@
use std::collections::BTreeSet;
use crate::{ use crate::{
durability::Durability, durability::Durability,
hash::{FxHashSet, FxIndexMap, FxIndexSet}, hash::{FxHashSet, FxIndexMap, FxIndexSet},
@ -36,15 +34,8 @@ pub(super) struct ActiveQuery {
/// Otherwise it is 1 more than the current value (which is incremented). /// Otherwise it is 1 more than the current value (which is incremented).
pub(super) disambiguator_map: FxIndexMap<u64, Disambiguator>, pub(super) disambiguator_map: FxIndexMap<u64, Disambiguator>,
/// Tracks values written by this query. Could be... /// Tracks entities created by this query.
/// pub(super) entities_created: FxHashSet<DatabaseKeyIndex>,
/// * tracked structs created
/// * invocations of `specify`
/// * accumulators pushed to
///
/// We use a btree-set because we want to be able to
/// extract the keys in sorted order.
pub(super) outputs: BTreeSet<DatabaseKeyIndex>,
} }
impl ActiveQuery { impl ActiveQuery {
@ -57,7 +48,7 @@ impl ActiveQuery {
untracked_read: false, untracked_read: false,
cycle: None, cycle: None,
disambiguator_map: Default::default(), disambiguator_map: Default::default(),
outputs: Default::default(), entities_created: Default::default(),
} }
} }
@ -84,15 +75,13 @@ impl ActiveQuery {
self.changed_at = self.changed_at.max(revision); self.changed_at = self.changed_at.max(revision);
} }
/// Adds a key to our list of outputs. pub(super) fn add_entity_created(&mut self, entity: DatabaseKeyIndex) {
pub(super) fn add_output(&mut self, key: DatabaseKeyIndex) { let is_new = self.entities_created.insert(entity);
let is_new = self.outputs.insert(key);
assert!(is_new); assert!(is_new);
} }
/// True if the given key was output by this query. pub(super) fn was_entity_created(&self, entity: DatabaseKeyIndex) -> bool {
pub(super) fn is_output(&self, key: DatabaseKeyIndex) -> bool { self.entities_created.contains(&entity)
self.outputs.contains(&key)
} }
pub(crate) fn revisions(&self, runtime: &Runtime) -> QueryRevisions { pub(crate) fn revisions(&self, runtime: &Runtime) -> QueryRevisions {

View file

@ -118,7 +118,7 @@ impl LocalState {
pub(super) fn add_entity_created(&self, entity: DatabaseKeyIndex) { pub(super) fn add_entity_created(&self, entity: DatabaseKeyIndex) {
self.with_query_stack(|stack| { self.with_query_stack(|stack| {
if let Some(top_query) = stack.last_mut() { if let Some(top_query) = stack.last_mut() {
top_query.add_output(entity) top_query.add_entity_created(entity)
} }
}) })
} }
@ -126,7 +126,7 @@ impl LocalState {
pub(super) fn was_entity_created(&self, entity: DatabaseKeyIndex) -> bool { pub(super) fn was_entity_created(&self, entity: DatabaseKeyIndex) -> bool {
self.with_query_stack(|stack| { self.with_query_stack(|stack| {
if let Some(top_query) = stack.last_mut() { if let Some(top_query) = stack.last_mut() {
top_query.is_output(entity) top_query.was_entity_created(entity)
} else { } else {
false false
} }