Skip to content

Commit

Permalink
Add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaReiser committed Sep 21, 2024
1 parent 2d55e83 commit a5396a9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/function/diff_outputs.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use super::{memo::Memo, Configuration, IngredientImpl};
use crate::tracked_struct::KeyStruct;
use crate::{
hash::FxHashSet, key::DependencyIndex, zalsa_local::QueryRevisions, AsDynDatabase as _,
DatabaseKeyIndex, Event, EventKind,
Expand All @@ -10,6 +11,9 @@ where
{
/// Compute the old and new outputs and invoke the `clear_stale_output` callback
/// for each output that was generated before but is not generated now.
///
/// This function takes a `&mut` reference to `revisions` to remove outputs
/// that no longer exist in this revision from [`QueryRevisions::tracked_struct_ids`].
pub(super) fn diff_outputs(
&self,
db: &C::DbView,
Expand All @@ -27,6 +31,8 @@ where
}

if !old_outputs.is_empty() {
// Remove the outputs that are no longer present in the current revision
// to prevent that the next revision is seeded with a id mapping that no longer exists.
revisions.tracked_struct_ids.retain(|_k, value| {
!old_outputs.contains(&DependencyIndex {
ingredient_index: value.ingredient_index,
Expand Down
7 changes: 6 additions & 1 deletion src/zalsa_local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,12 @@ pub(crate) struct QueryRevisions {

/// The ids of tracked structs created by this query.
/// This is used to seed the next round if the query is
/// re-executed.
/// re-executed. This ensures that tracked structs
/// have the same id across revisions.
///
/// [`diff_outputs`] removes tracked structs that were created
/// in a previous revision but no longer exist
/// in the new revision.
pub(super) tracked_struct_ids: FxHashMap<KeyStruct, DatabaseKeyIndex>,
}

Expand Down

0 comments on commit a5396a9

Please sign in to comment.