diff --git a/crates/improvise-command/src/command/cmd/determinism.rs b/crates/improvise-command/src/command/cmd/determinism.rs index 66a0a223..fd978aff 100644 --- a/crates/improvise-command/src/command/cmd/determinism.rs +++ b/crates/improvise-command/src/command/cmd/determinism.rs @@ -61,13 +61,12 @@ fn one_coordinate_drills(model: &Model) -> Vec> { drills } -/// Records a compared drill's own effects freeze in a fresh `App`, counted only when -/// the drill narrowed the store: a whole-store drill never reads the index. -fn records_narrowed(effects: Vec>) -> usize { - let mut app = fixture(); - let store = app.model_state.workbook.model.data.live_records().count(); - app.apply_effects(effects); - let frozen = app.drill_state.map_or(0, |drill| drill.records.len()); +/// Records a compared drill's own effects freeze in `scratch`, counted only when the +/// drill narrowed the store: a whole-store drill never reads the index. +fn records_narrowed(scratch: &mut App, effects: Vec>) -> usize { + let store = scratch.model_state.workbook.model.data.live_records().count(); + scratch.apply_effects(effects); + let frozen = scratch.drill_state.as_ref().map_or(0, |drill| drill.records.len()); if frozen < store { frozen } else { 0 } } @@ -116,6 +115,7 @@ fn compare(a: &CmdContext, others: &[CmdContext]) -> Comparison { let drill = DrillIntoCell { key: CellKey::new(vec![]), }; + let mut scratch = fixture(); for name in a.registry.names().collect::>() { let before = found.compared; for args in &candidates { @@ -124,7 +124,7 @@ fn compare(a: &CmdContext, others: &[CmdContext]) -> Comparison { }; let left = format!("{effects:?}"); if name == drill.name() { - found.widest_drill = found.widest_drill.max(records_narrowed(effects)); + found.widest_drill = found.widest_drill.max(records_narrowed(&mut scratch, effects)); } found.compared += 1; for b in others {