From 0214dbc1d615db32d011322b8021299364aa754a Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Fri, 14 Jan 2022 21:03:11 -0800 Subject: [PATCH] Break ctables_cell_insert__() from ctables_cell_add__() --- src/language/stats/ctables.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/src/language/stats/ctables.c b/src/language/stats/ctables.c index ca2cfd9b66..2e0b51334f 100644 --- a/src/language/stats/ctables.c +++ b/src/language/stats/ctables.c @@ -2206,11 +2206,10 @@ ctables_categories_total (const struct ctables_categories *c) : NULL); } -static void +static struct ctables_cell * ctables_cell_insert__ (struct ctables_table *t, const struct ccase *c, size_t ix[PIVOT_N_AXES], - const struct ctables_category *cats[PIVOT_N_AXES][10], - double weight) + const struct ctables_category *cats[PIVOT_N_AXES][10]) { const struct ctables_nest *ss = &t->stacks[t->summary_axis].nests[ix[t->summary_axis]]; @@ -2254,7 +2253,7 @@ ctables_cell_insert__ (struct ctables_table *t, const struct ccase *c, goto not_equal; } - goto summarize; + return cell; not_equal: ; } @@ -2294,8 +2293,18 @@ ctables_cell_insert__ (struct ctables_table *t, const struct ccase *c, for (enum ctables_domain_type dt = 0; dt < N_CTDTS; dt++) cell->domains[dt] = ctables_domain_insert (t, cell, dt); hmap_insert (&t->cells, &cell->node, hash); + return cell; +} + +static void +ctables_cell_add__ (struct ctables_table *t, const struct ccase *c, + size_t ix[PIVOT_N_AXES], + const struct ctables_category *cats[PIVOT_N_AXES][10], + double weight) +{ + struct ctables_cell *cell = ctables_cell_insert__ (t, c, ix, cats); + const struct ctables_nest *ss = &t->stacks[t->summary_axis].nests[ix[t->summary_axis]]; -summarize: ; const struct ctables_summary_spec_set *sss = (cell->total ? &ss->total_sss : &ss->cell_sss); for (size_t i = 0; i < sss->n; i++) @@ -2328,7 +2337,7 @@ recurse_totals (struct ctables_table *t, const struct ccase *c, { const struct ctables_category *save = cats[a][i]; cats[a][i] = total; - ctables_cell_insert__ (t, c, ix, cats, weight); + ctables_cell_add__ (t, c, ix, cats, weight); recurse_totals (t, c, ix, cats, weight, a, i + 1); cats[a][i] = save; } @@ -2371,7 +2380,7 @@ ctables_cell_insert (struct ctables_table *t, } } - ctables_cell_insert__ (t, c, ix, cats, weight); + ctables_cell_add__ (t, c, ix, cats, weight); recurse_totals (t, c, ix, cats, weight, 0, 0); @@ -2387,7 +2396,7 @@ ctables_cell_insert (struct ctables_table *t, if (save->subtotal) { cats[a][i] = save->subtotal; - ctables_cell_insert__ (t, c, ix, cats, weight); + ctables_cell_add__ (t, c, ix, cats, weight); cats[a][i] = save; } } -- 2.30.2