Add comments

This commit is contained in:
Micha Reiser 2024-09-21 16:34:42 +02:00
parent 2d55e83845
commit a5396a9142
No known key found for this signature in database
2 changed files with 12 additions and 1 deletions

View file

@ -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,
@ -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,
@ -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,

View file

@ -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>,
}