File tree 2 files changed +28
-11
lines changed
2 files changed +28
-11
lines changed Original file line number Diff line number Diff line change @@ -119,6 +119,16 @@ impl CycleHeads {
119
119
. any ( |head| head. database_key_index == * value)
120
120
}
121
121
122
+ pub ( crate ) fn contains_at_iteration (
123
+ & self ,
124
+ database_key_index : DatabaseKeyIndex ,
125
+ iteration_count : u32 ,
126
+ ) -> bool {
127
+ self . into_iter ( ) . any ( |head| {
128
+ head. database_key_index == database_key_index && head. iteration_count == iteration_count
129
+ } )
130
+ }
131
+
122
132
pub ( crate ) fn remove ( & mut self , value : & DatabaseKeyIndex ) -> bool {
123
133
let Some ( cycle_heads) = & mut self . 0 else {
124
134
return false ;
@@ -134,6 +144,10 @@ impl CycleHeads {
134
144
true
135
145
}
136
146
147
+ pub ( crate ) fn len ( & self ) -> usize {
148
+ self . 0 . as_ref ( ) . map ( |heads| heads. len ( ) ) . unwrap_or_default ( )
149
+ }
150
+
137
151
pub ( crate ) fn update_iteration_count (
138
152
& mut self ,
139
153
cycle_head_index : DatabaseKeyIndex ,
Original file line number Diff line number Diff line change @@ -276,18 +276,21 @@ where
276
276
"{database_key_index:?}: validate_same_iteration(memo = {memo:#?})" ,
277
277
memo = memo. tracing_debug( )
278
278
) ;
279
- for cycle_head in & memo. revisions . cycle_heads {
280
- if !db. zalsa_local ( ) . with_query_stack ( |stack| {
281
- stack. iter ( ) . any ( |entry| {
282
- entry. database_key_index == cycle_head. database_key_index
283
- && entry. iteration_count == cycle_head. iteration_count
284
- } )
285
- } ) {
286
- return false ;
287
- }
288
- }
289
279
290
- true
280
+ let heads = & memo. revisions . cycle_heads ;
281
+ let num_heads = heads. len ( ) ;
282
+ db. zalsa_local ( ) . with_query_stack ( |stack| {
283
+ let mut found = 0 ;
284
+ for entry in stack. iter ( ) {
285
+ if heads. contains_at_iteration ( entry. database_key_index , entry. iteration_count ) {
286
+ found += 1 ;
287
+ if found == num_heads {
288
+ return true ;
289
+ }
290
+ }
291
+ }
292
+ false
293
+ } )
291
294
}
292
295
293
296
/// VerifyResult::Unchanged if the memo's value and `changed_at` time is up-to-date in the
You can’t perform that action at this time.
0 commit comments