From 1ce504148e960fa8fdd3701977786b99a7437f57 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Tue, 3 Apr 2012 11:20:41 -0700 Subject: * eval.c (op_modplace): push replaced with mpush (mutating push). * gc.c (gc_push): New function. * gc.h (gc_push): Declared. * hash.c (pushhash): Use mpush. * lib.c (push): Reverted to unsafe operation. TODO comment replaced with warning. (lazy_flatten_scan): push occurence commented as safe. (lazy_stream_func): Unsafe push replaced with mpush. * lib.h (mpush): New macro. --- lib.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'lib.c') diff --git a/lib.c b/lib.c index 436a47ee..4cef5ba4 100644 --- a/lib.c +++ b/lib.c @@ -361,9 +361,8 @@ val pop(val *plist) val push(val value, val *plist) { - /* TODO: doing set here is suboptimal since - it is often used for just a local var. */ - return set(*plist, cons(value, *plist)); + /* Unsafe for mutating object fields: use mpush macro. */ + return *plist = cons(value, *plist); } val copy_list(val list) @@ -759,7 +758,7 @@ static val lazy_flatten_scan(val list, val *escape) } else if (atom(a)) { return list; } else do { - push(cdr(list), escape); + push(cdr(list), escape); /* safe mutation: *escape is a local var */ list = a; a = car(list); } while (consp(a)); @@ -3328,7 +3327,7 @@ static val lazy_stream_func(val env, val lcons) close_stream(stream, t); if (ahead) - push(ahead, cdr_l(env)); + mpush(ahead, *cdr_l(env)); return next; } -- cgit v1.2.3