Reuse remembered range sums for every COUNT block

COUNT never reads the running sum, so the zero-sum gate that keeps SUM
and AVERAGE additions in order does not apply to it.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
vangel76
2026-11-07 16:58:19 +01:00
co-authored by Claude Sonnet 5.5
parent 00f565bc11
commit 76002fe0bd
+2 -1
View File
@@ -384,7 +384,8 @@ impl<'h> Evaluator<'h> {
fn aggregate_area(&mut self, kind: Agg, a: &Area, acc: &mut Acc) -> Result<(), Ev> {
if !a.range.is_single() {
// Adding the block's remembered sum to anything but +0.0 would add in another order.
if acc.sum.to_bits() == 0
// COUNT never reads the sum, so it may reuse every block.
if (kind == Agg::Count || acc.sum.to_bits() == 0)
&& let Some((sum, count)) = self.host.range_sum(a.sheet, a.range)
{
acc.sum = sum;