Simplify num_ctl_zs

This commit is contained in:
wborgeaud 2022-09-29 16:32:41 +02:00
parent 1de3ed823a
commit cb620bc55a

View File

@ -193,18 +193,12 @@ impl<F: Field> CrossTableLookup<F> {
}
pub(crate) fn num_ctl_zs(ctls: &[Self], table: Table, num_challenges: usize) -> usize {
let mut ans = 0;
let mut num_ctls = 0;
for ctl in ctls {
ans += ctl
.looking_tables
.iter()
.filter_map(|twc| (twc.table == table).then_some(num_challenges))
.sum::<usize>();
ans += (ctl.looked_table.table == table)
.then_some(num_challenges)
.unwrap_or_default();
let all_tables = std::iter::once(&ctl.looked_table).chain(&ctl.looking_tables);
num_ctls += all_tables.filter(|twc| twc.table == table).count();
}
ans
num_ctls * num_challenges
}
}