From 6ac45e04ea817dcd6df3a749f523ed1b96ec0118 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Mon, 1 Jan 2018 19:56:11 -0800 Subject: Use rplaca and rplacd instead of set over car_l/cdr_l. This reduces the proliferation of car_l and cdr_l. With this change, nreverse should work on chains of objects that implement rplacd. * combi.c (comb_gen_fun_common, rcomb_gen_fun_common): Use rplaca. * eval.c (mappendv, mapdov): Likewise * hash.c (hash_equal_op): Likewise. * lib.c (nreverse, acons_new, aconsql_new, sort_list): Use rplaca and rplacd. * match.c (dest_set, v_gather, v_collect, v_flatten, v_cat, v_output, v_filter): Likewise * parser.c (ensure_parser): Use sys_rplacd. * unwind.c (uw_register_subtype): Use rplacd. --- combi.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'combi.c') diff --git a/combi.c b/combi.c index c749b300..aea2032c 100644 --- a/combi.c +++ b/combi.c @@ -359,7 +359,7 @@ static void comb_gen_fun_common(val state) val curr = first(iter); val curr_rest = rest(curr); if (curr_rest != prev && consp(curr_rest)) { - set(car_l(iter), curr_rest); + rplaca(iter, curr_rest); return; } else if (rest(iter)) { val next = second(iter); @@ -367,11 +367,11 @@ static void comb_gen_fun_common(val state) val next_rest_rest = rest(next_rest); prev = curr; if (next_rest != curr && consp(next_rest_rest)) - prev = set(car_l(iter), next_rest_rest); + prev = sys_rplaca(iter, next_rest_rest); } } - deref(car_l(state)) = nil; + rplaca(state, nil); } static val comb_list_gen_fun(val state) @@ -520,16 +520,16 @@ static void rcomb_gen_fun_common(val state) if (consp(curr_rest)) { val jter; for (jter = state; jter != next; jter = cdr(jter)) - set(car_l(jter), curr_rest); + rplaca(jter, curr_rest); return; } else if (next) { val next = second(iter); if (curr != next) - set(car_l(iter), rest(next)); + rplaca(iter, rest(next)); } } - deref(car_l(state)) = nil; + rplaca(state, nil); } static val rcomb_list_gen_fun(val state) -- cgit v1.2.3