- for (j = ARR_LEN(Q) - 1; j >= 0; --j) {
- partition_t *Z = Q[j];
-
- for (k = Z->max_arity - 1; k >= -1; --k) {
- if (Z->n_nodes > 1) {
- env->lambda_input = k;
- DB((dbg, LEVEL_2, "WHAT = lambda n.(n[%d].partition) on part%d\n", k, Z->nr));
- split_by_what(Z, lambda_partition, NULL, env);
+ do {
+ list_head hR, hS;
+ partition_t *Z = list_entry(Q->next, partition_t, split_list);
+ int max_arity = Z->max_arity;
+ list_head *R = &hR, *S = &hS, *T;
+
+ list_del(&Z->split_list);
+
+ if (Z->n_nodes > 1) {
+ INIT_LIST_HEAD(R);
+ INIT_LIST_HEAD(S);
+
+ /*
+ * BEWARE: during splitting by input 2 for instance we might
+ * create new partitions which are different by input 1, so collect
+ * them and split further.
+ */
+ list_add(&Z->split_list, R);
+ for (input = max_arity - 1; input >= -1; --input) {
+ do {
+ partition_t *Z_prime = list_entry(R->next, partition_t, split_list);
+
+ list_del(&Z_prime->split_list);
+ if (Z_prime->n_nodes > 1) {
+ env->lambda_input = input;
+ DB((dbg, LEVEL_2, "WHAT = lambda n.(n[%d].partition) on part%d\n", input, Z_prime->nr));
+ S = split_by_what(Z_prime, lambda_partition, S, env);
+ } else {
+ list_add(&Z_prime->split_list, S);
+ }
+ } while (!list_empty(R));
+ T = R;
+ R = S;
+ S = T;