@@ -588,11 +588,9 @@ where
588
588
// The `MaybeChangeAfterCycleHeads` is used as an out parameter and it's
589
589
// the caller's responsibility to pass an empty `heads`, which is what we do here.
590
590
let mut inner_cycle_heads = VerifyCycleHeads {
591
- heads : std:: mem:: take ( & mut child_cycle_heads) ,
592
- participating_queries : std:: mem:: take (
593
- & mut cycle_heads. participating_queries ,
594
- ) ,
595
591
has_outer_cycles : cycle_heads. has_any ( ) ,
592
+ heads : & mut child_cycle_heads,
593
+ participating_queries : cycle_heads. participating_queries ,
596
594
} ;
597
595
598
596
let input_result = dependency_index. maybe_changed_after (
@@ -602,10 +600,6 @@ where
602
600
& mut inner_cycle_heads,
603
601
) ;
604
602
605
- // Reuse the cycle head allocation.
606
- child_cycle_heads = inner_cycle_heads. heads ;
607
- cycle_heads. participating_queries =
608
- inner_cycle_heads. participating_queries ;
609
603
// Aggregate the cycle heads into the parent cycle heads
610
604
cycle_heads. append_heads ( & mut child_cycle_heads) ;
611
605
@@ -756,23 +750,34 @@ impl ShallowUpdate {
756
750
/// aren't included.
757
751
///
758
752
/// [`maybe_changed_after`]: crate::ingredient::Ingredient::maybe_changed_after
759
- #[ derive( Debug , Default ) ]
760
- pub struct VerifyCycleHeads {
753
+ #[ derive( Debug ) ]
754
+ pub struct VerifyCycleHeads < ' a > {
761
755
/// The cycle heads encountered while verifying this ingredient and its subtree.
762
- heads : Vec < DatabaseKeyIndex > ,
756
+ heads : & ' a mut Vec < DatabaseKeyIndex > ,
763
757
764
758
/// The cached `maybe_changed_after` results for queries that participate in cycles but aren't a cycle head
765
759
/// themselves. We need to cache the results here to avoid calling `deep_verify_memo` repeatedly
766
760
/// for queries that have cyclic dependencies (b depends on a (iteration 0) and a depends on b(iteration 1))
767
761
/// as well as to avoid a run-away situation if a query is dependet on a lot inside a single cycle.
768
- participating_queries : FxHashMap < DatabaseKeyIndex , VerifyResult > ,
762
+ participating_queries : & ' a mut FxHashMap < DatabaseKeyIndex , VerifyResult > ,
769
763
770
764
/// Whether the outer query (e.g. the parent query running `maybe_changed_after`) has encountered
771
765
/// any cycles to this point.
772
766
has_outer_cycles : bool ,
773
767
}
774
768
775
- impl VerifyCycleHeads {
769
+ impl < ' a > VerifyCycleHeads < ' a > {
770
+ pub ( crate ) fn new (
771
+ heads : & ' a mut Vec < DatabaseKeyIndex > ,
772
+ participating_queries : & ' a mut FxHashMap < DatabaseKeyIndex , VerifyResult > ,
773
+ ) -> Self {
774
+ Self {
775
+ heads,
776
+ participating_queries,
777
+ has_outer_cycles : false ,
778
+ }
779
+ }
780
+
776
781
/// Returns `true` if this query or any of its dependencies depend on this cycle.
777
782
#[ inline]
778
783
fn contains_head ( & self , key : DatabaseKeyIndex ) -> bool {
0 commit comments