26
26
mut active_query : ActiveQueryGuard < ' db > ,
27
27
opt_old_memo : Option < & Memo < C :: Output < ' _ > > > ,
28
28
) -> & ' db Memo < C :: Output < ' db > > {
29
- let ( zalsa, zalsa_local ) = db. zalsas ( ) ;
29
+ let zalsa = db. zalsa ( ) ;
30
30
let revision_now = zalsa. current_revision ( ) ;
31
31
let database_key_index = active_query. database_key_index ;
32
32
let id = database_key_index. key_index ( ) ;
@@ -65,32 +65,21 @@ where
65
65
if C :: CYCLE_STRATEGY == CycleRecoveryStrategy :: Fixpoint
66
66
&& revisions. cycle_heads . contains ( & database_key_index)
67
67
{
68
- let opt_owned_last_provisional;
69
68
let last_provisional_value = if let Some ( last_provisional) = opt_last_provisional {
70
69
// We have a last provisional value from our previous time around the loop.
71
- last_provisional
72
- . value
73
- . as_ref ( )
74
- . expect ( "provisional value should not be evicted by LRU" )
70
+ last_provisional. value . as_ref ( )
75
71
} else {
76
72
// This is our first time around the loop; a provisional value must have been
77
73
// inserted into the memo table when the cycle was hit, so let's pull our
78
74
// initial provisional value from there.
79
- opt_owned_last_provisional =
80
- self . get_memo_from_table_for ( zalsa, id, memo_ingredient_index) ;
81
- debug_assert ! ( opt_owned_last_provisional
82
- . as_ref( )
83
- . unwrap( )
84
- . may_be_provisional( ) ) ;
85
- opt_owned_last_provisional
86
- . expect (
87
- "{database_key_index:#?} is a cycle head, \
88
- but no provisional memo found",
89
- )
90
- . value
91
- . as_ref ( )
92
- . expect ( "provisional value should not be evicted by LRU" )
75
+ let memo =
76
+ self . get_memo_from_table_for ( zalsa, id, memo_ingredient_index)
77
+ . unwrap_or_else ( || panic ! ( "{database_key_index:#?} is a cycle head, but no provisional memo found" ) ) ;
78
+ debug_assert ! ( memo. may_be_provisional( ) ) ;
79
+ memo. value . as_ref ( )
93
80
} ;
81
+ // SAFETY: The `LRU` does not run mid-execution, so the value remains filled
82
+ let last_provisional_value = unsafe { last_provisional_value. unwrap_unchecked ( ) } ;
94
83
tracing:: debug!(
95
84
"{database_key_index:?}: execute: \
96
85
I am a cycle head, comparing last provisional value with new value"
@@ -130,9 +119,9 @@ where
130
119
fell_back = true ;
131
120
}
132
121
}
133
- iteration_count = iteration_count
134
- . checked_add ( 1 )
135
- . expect ( "fixpoint iteration should converge before u32::MAX iterations" ) ;
122
+ // ` iteration_count` can't overflow as we check it against `MAX_ITERATIONS`
123
+ // which is less than `u32::MAX`.
124
+ iteration_count += 1 ;
136
125
if iteration_count > MAX_ITERATIONS {
137
126
panic ! ( "{database_key_index:?}: execute: too many cycle iterations" ) ;
138
127
}
@@ -143,7 +132,7 @@ where
143
132
memo_ingredient_index,
144
133
) ) ;
145
134
146
- active_query = zalsa_local. push_query ( database_key_index) ;
135
+ active_query = db . zalsa_local ( ) . push_query ( database_key_index) ;
147
136
148
137
continue ;
149
138
}
0 commit comments