summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2019-03-15 07:06:38 -0700
committerKaz Kylheku <kaz@kylheku.com>2019-03-15 07:06:38 -0700
commit068b0cc761a6f17312057d65804d90f2579a7593 (patch)
tree8f8132709c5aa79ad9d1058aab5263d2aab8009d
parent10b17a4563985a76c9d107cba4264f3327786856 (diff)
downloadtxr-068b0cc761a6f17312057d65804d90f2579a7593.tar.gz
txr-068b0cc761a6f17312057d65804d90f2579a7593.tar.bz2
txr-068b0cc761a6f17312057d65804d90f2579a7593.zip
flatcar*: eliminate state cons.
* lib.c (lazy_flatcar_func, lazy_flatcar): Here, the state information consists of just one value. We just make that value itself the function's env, and mutate that env as needed.
-rw-r--r--lib.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/lib.c b/lib.c
index 899ba9ba..e6ac7c48 100644
--- a/lib.c
+++ b/lib.c
@@ -2250,17 +2250,17 @@ static val lazy_flatcar_scan(val tree, val *cont)
}
}
-static val lazy_flatcar_func(val env, val lcons)
+static val lazy_flatcar_func(val tree, val lcons)
{
- val tree = us_car(env);
val cont = nil;
val atom = lazy_flatcar_scan(tree, &cont);
+ val fun = us_lcons_fun(lcons);
rplaca(lcons, atom);
- rplaca(env, cont);
+ us_func_set_env(fun, cont);
if (cont)
- us_rplacd(lcons, make_lazy_cons(us_lcons_fun(lcons)));
+ us_rplacd(lcons, make_lazy_cons(fun));
return nil;
}
@@ -2276,7 +2276,7 @@ val lazy_flatcar(val tree)
if (!cont)
return cons(nextatom, nil);
- return make_lazy_cons(func_f1(cons(tree, nil), lazy_flatcar_func));
+ return make_lazy_cons(func_f1(tree, lazy_flatcar_func));
}
}