From cce7a7d2bcb1b144d87b42f34fb295ee813eaff2 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Mon, 6 Jun 2016 06:30:30 -0700 Subject: Use local var in list_collect_{nconc,append}. * lib.c (list_collect_nconc, list_collect_append): Capture deref(ptail) subexpression in local var and refer to that in all code where ptail isn't modified from the original value. --- lib.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'lib.c') diff --git a/lib.c b/lib.c index f6e740fd..8807a189 100644 --- a/lib.c +++ b/lib.c @@ -783,56 +783,58 @@ loc list_collect(loc ptail, val obj) loc list_collect_nconc(loc ptail, val obj) { + val tailobj = deref(ptail); obj = nullify(obj); - switch (type(deref(ptail))) { + switch (type(tailobj)) { case NIL: set(ptail, obj); return ptail; case CONS: case LCONS: - ptail = tail(deref(ptail)); + ptail = tail(tailobj); set(ptail, obj); return ptail; case VEC: - replace_vec(deref(ptail), obj, t, t); + replace_vec(tailobj, obj, t, t); return ptail; case STR: case LIT: case LSTR: - replace_str(deref(ptail), obj, t, t); + replace_str(tailobj, obj, t, t); return ptail; default: - uw_throwf(error_s, lit("cannot nconc ~s to ~s"), obj, deref(ptail), nao); + uw_throwf(error_s, lit("cannot nconc ~s to ~s"), obj, tailobj, nao); } } loc list_collect_append(loc ptail, val obj) { + val tailobj = deref(ptail); obj = nullify(obj); - switch (type(deref(ptail))) { + switch (type(tailobj)) { case NIL: set(ptail, obj); return ptail; case CONS: case LCONS: - set(ptail, copy_list(deref(ptail))); + set(ptail, copy_list(tailobj)); ptail = tail(deref(ptail)); set(ptail, obj); return ptail; case VEC: - set(ptail, copy_vec(deref(ptail))); + set(ptail, copy_vec(tailobj)); replace_vec(deref(ptail), obj, t, t); return ptail; case STR: case LIT: case LSTR: - set(ptail, copy_str(deref(ptail))); + set(ptail, copy_str(tailobj)); replace_str(deref(ptail), obj, t, t); return ptail; default: - uw_throwf(error_s, lit("cannot append to ~s"), deref(ptail), nao); + uw_throwf(error_s, lit("cannot append to ~s"), tailobj, nao); } } -- cgit v1.2.3