refacotring 2?
[pspp] / src / language / stats / ctables.c
index c3c797a52c0fb6d814e3aa4f27f071d31824af64..01c16cc1e98a14f3315fbb433b8e726be61c1c2b 100644 (file)
@@ -4702,18 +4702,16 @@ ctables_prepare_table (struct ctables_table *t)
                   if (k != nest->scale_idx)
                     nest->areas[at][nest->n_areas[at]++] = k;
 
-                int n_drop = 0;
+                int n_drop;
                 switch (at)
                   {
                   case CTAT_SUBTABLE:
-                    if (t->clabels_from_axis == PIVOT_AXIS_LAYER)
-                      n_drop = a != PIVOT_AXIS_LAYER;
-                    else if (t->clabels_to_axis != PIVOT_AXIS_LAYER)
-                      n_drop = a == t->clabels_from_axis ? 2 : 0;
-                    else if (a == t->clabels_from_axis)
-                      n_drop = -1;
-                    else
-                      n_drop = a != PIVOT_AXIS_LAYER;
+#define L PIVOT_AXIS_LAYER
+                    n_drop = (t->clabels_from_axis == L ? a != L
+                              : t->clabels_to_axis == L ? (a == t->clabels_from_axis ? -1 : a != L)
+                              : a == t->clabels_from_axis ? 2
+                              : 0);
+#undef L
                     break;
 
                   case CTAT_LAYERROW:
@@ -4723,19 +4721,16 @@ ctables_prepare_table (struct ctables_table *t)
 
                   case CTAT_ROW:
                   case CTAT_COL:
-                    if (a == atb)
-                      {
-                        if (t->clabels_from_axis == atb)
-                          n_drop = -1;
-                        else if (t->clabels_to_axis != atb)
-                          n_drop = 1;
-                      }
-                    else if (a == ata)
-                      n_drop = t->label_axis[ata] == atb;
+                    n_drop = (a == ata ? t->label_axis[ata] == atb
+                              : a != atb ? 0
+                              : t->clabels_from_axis == atb ? -1
+                              : t->clabels_to_axis != atb ? 1
+                              : 0);
                     break;
 
                   case CTAT_LAYER:
                   case CTAT_TABLE:
+                    n_drop = 0;
                     break;
                   }