Skip to content

Commit 736e66e

Browse files
authored
[refactor] Reuse the same stack for all cycles heads in validate_same_iteration (#791)
1 parent 87bf6b6 commit 736e66e

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

src/function/maybe_changed_after.rs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -293,18 +293,21 @@ where
293293
"{database_key_index:?}: validate_same_iteration(memo = {memo:#?})",
294294
memo = memo.tracing_debug()
295295
);
296-
for cycle_head in &memo.revisions.cycle_heads {
297-
if !db.zalsa_local().with_query_stack(|stack| {
298-
stack.iter().rev().any(|entry| {
299-
entry.database_key_index == cycle_head.database_key_index
300-
&& entry.iteration_count() == cycle_head.iteration_count
301-
})
302-
}) {
303-
return false;
304-
}
296+
297+
if memo.revisions.cycle_heads.is_empty() {
298+
return true;
305299
}
306300

307-
true
301+
let cycle_heads = &memo.revisions.cycle_heads;
302+
303+
db.zalsa_local().with_query_stack(|stack| {
304+
cycle_heads.iter().all(|cycle_head| {
305+
stack.iter().rev().any(|query| {
306+
query.database_key_index == cycle_head.database_key_index
307+
&& query.iteration_count() == cycle_head.iteration_count
308+
})
309+
})
310+
})
308311
}
309312

310313
/// VerifyResult::Unchanged if the memo's value and `changed_at` time is up-to-date in the

0 commit comments

Comments
 (0)