diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2016-05-15 22:59:38 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2016-05-15 22:59:38 -0700 |
commit | 3df89b1573d415bb18a912c4c774edc189b1ac11 (patch) | |
tree | a1ecc6d98e9aa5a420132e6cd2e546e29a1dd0e8 /lib.c | |
parent | 506cb6b8dfd3ad55bc0bef4701bbea396e9b05ac (diff) | |
download | txr-3df89b1573d415bb18a912c4c774edc189b1ac11.tar.gz txr-3df89b1573d415bb18a912c4c774edc189b1ac11.tar.bz2 txr-3df89b1573d415bb18a912c4c774edc189b1ac11.zip |
Some streamlining in the cons recycling.
* lib.c (rcyc_pop): Just assume that *plist points to a cons
and access the fields directly.
(rcyc_cons): Don't bother with rplacd.
(rcyc_list): Don't bother with set macro.
* regex.c (read_until_match): Defensive coding: locally
ensure that rcyc_pop won't be called on a nil stack,
which will now segfault.
Diffstat (limited to 'lib.c')
-rw-r--r-- | lib.c | 18 |
1 files changed, 8 insertions, 10 deletions
@@ -605,8 +605,8 @@ val pop(val *plist) val rcyc_pop(val *plist) { val rcyc = *plist; - val ret = car(rcyc); - *plist = cdr(rcyc); + val ret = rcyc->c.car; + *plist = rcyc->c.cdr; rcyc_cons(rcyc); return ret; } @@ -2535,7 +2535,7 @@ val make_half_lazy_cons(val func, val car) void rcyc_cons(val cons) { - rplacd(cons, recycled_conses); + cons->c.cdr = recycled_conses; cons->c.car = nil; recycled_conses = cons; } @@ -2545,13 +2545,11 @@ void rcyc_list(val list) if (list) { val rl_orig = recycled_conses; recycled_conses = list; - for (; list; list = list->c.cdr) { - list->c.car = nil; - if (!list->c.cdr) { - set(mkloc(list->lc.cdr, list), rl_orig); - break; - } - } + + while (list->c.cdr) + list = list->c.cdr; + + list->c.cdr = rl_orig; } } |