summaryrefslogtreecommitdiffstats
path: root/lib.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2016-06-06 06:30:30 -0700
committerKaz Kylheku <kaz@kylheku.com>2016-06-06 06:30:30 -0700
commitcce7a7d2bcb1b144d87b42f34fb295ee813eaff2 (patch)
tree0d7bb6a973831e7752e69e35f351f2add45ce86b /lib.c
parent9566faf500204b93230f532c879662528f53815f (diff)
downloadtxr-cce7a7d2bcb1b144d87b42f34fb295ee813eaff2.tar.gz
txr-cce7a7d2bcb1b144d87b42f34fb295ee813eaff2.tar.bz2
txr-cce7a7d2bcb1b144d87b42f34fb295ee813eaff2.zip
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.
Diffstat (limited to 'lib.c')
-rw-r--r--lib.c22
1 files changed, 12 insertions, 10 deletions
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);
}
}