start making code cleaner
authorBen Pfaff <blp@cs.stanford.edu>
Sun, 14 Aug 2022 00:10:39 +0000 (17:10 -0700)
committerBen Pfaff <blp@cs.stanford.edu>
Sun, 14 Aug 2022 00:10:39 +0000 (17:10 -0700)
src/language/stats/ctables.c

index 4e872fc59fbd55e45c5a3c679eb2f14d5cdb08d6..918fed9a7b875327b78c1dcc92a5146b89b08da0 100644 (file)
@@ -4678,27 +4678,7 @@ ctables_prepare_table (struct ctables_table *t)
                         continue;
                       nest->areas[at][nest->n_areas[at]++] = k;
                     }
-                else if (at == CTAT_LAYERCOL && a == PIVOT_AXIS_ROW && t->label_axis[PIVOT_AXIS_ROW] == PIVOT_AXIS_COLUMN)
-                  {
-                    for (size_t k = nest->n - 1; k < nest->n; k--)
-                      {
-                        if (k == nest->scale_idx)
-                          continue;
-                        nest->areas[at][nest->n_areas[at]++] = k;
-                        break;
-                      }
-                  }
-                else if (at == CTAT_LAYERCOL && a == PIVOT_AXIS_ROW && t->label_axis[PIVOT_AXIS_ROW] == PIVOT_AXIS_LAYER)
-                  {
-                    for (size_t k = nest->n - 1; k < nest->n; k--)
-                      {
-                        if (k == nest->scale_idx)
-                          continue;
-                        nest->areas[at][nest->n_areas[at]++] = k;
-                        break;
-                      }
-                  }
-                else if (at == CTAT_LAYERROW && a == PIVOT_AXIS_COLUMN && t->label_axis[PIVOT_AXIS_COLUMN] == PIVOT_AXIS_LAYER)
+                else if (at == CTAT_LAYERCOL && a == PIVOT_AXIS_ROW && t->label_axis[a] != a)
                   {
                     for (size_t k = nest->n - 1; k < nest->n; k--)
                       {
@@ -4707,8 +4687,9 @@ ctables_prepare_table (struct ctables_table *t)
                         nest->areas[at][nest->n_areas[at]++] = k;
                         break;
                       }
+                    continue;
                   }
-                else if (at == CTAT_LAYERROW && a == PIVOT_AXIS_COLUMN && t->label_axis[PIVOT_AXIS_COLUMN] == PIVOT_AXIS_ROW)
+                else if (at == CTAT_LAYERROW && a == PIVOT_AXIS_COLUMN && t->label_axis[a] != a)
                   {
                     for (size_t k = nest->n - 1; k < nest->n; k--)
                       {
@@ -4717,6 +4698,7 @@ ctables_prepare_table (struct ctables_table *t)
                         nest->areas[at][nest->n_areas[at]++] = k;
                         break;
                       }
+                    continue;
                   }
                 else if (at == CTAT_LAYER && t->label_axis[a] == PIVOT_AXIS_LAYER)
                   {
@@ -4740,6 +4722,16 @@ ctables_prepare_table (struct ctables_table *t)
                         nest->n_areas[at]--;
                     continue;
                   }
+                else if (at == CTAT_SUBTABLE && t->label_axis[PIVOT_AXIS_COLUMN] == PIVOT_AXIS_ROW)
+                  {
+                    size_t n_drop = (a == PIVOT_AXIS_LAYER ? 0
+                                     : a == PIVOT_AXIS_COLUMN ? 2
+                                     : 0);
+                    for (size_t i = 0; i < n_drop; i++)
+                      if (nest->n_areas[at] > 0)
+                        nest->n_areas[at]--;
+                    continue;
+                  }
                 else if (at == CTAT_SUBTABLE && t->label_axis[PIVOT_AXIS_ROW] == PIVOT_AXIS_LAYER)
                   {
                     if (a == PIVOT_AXIS_ROW)
@@ -4776,16 +4768,6 @@ ctables_prepare_table (struct ctables_table *t)
                       }
                     continue;
                   }
-                else if (at == CTAT_SUBTABLE && t->label_axis[PIVOT_AXIS_COLUMN] == PIVOT_AXIS_ROW)
-                  {
-                    size_t n_drop = (a == PIVOT_AXIS_LAYER ? 0
-                                     : a == PIVOT_AXIS_COLUMN ? 2
-                                     : 0);
-                    for (size_t i = 0; i < n_drop; i++)
-                      if (nest->n_areas[at] > 0)
-                        nest->n_areas[at]--;
-                    continue;
-                  }
                 else if (at == CTAT_ROW && a == PIVOT_AXIS_COLUMN && t->label_axis[PIVOT_AXIS_ROW] == PIVOT_AXIS_COLUMN)
                   continue;
                 else if (at == CTAT_COL && a == PIVOT_AXIS_ROW && t->label_axis[PIVOT_AXIS_ROW] == PIVOT_AXIS_COLUMN)