diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2019-09-07 05:04:51 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2019-09-07 05:04:51 -0700 |
commit | 13bba10fb47fa1b3638021120042641464f0c57a (patch) | |
tree | 18bc9d8f26b6f00d5edbc149041e7fadb3001061 | |
parent | 337e47fb140beea69af30d3e8f84307ee244afb4 (diff) | |
download | txr-13bba10fb47fa1b3638021120042641464f0c57a.tar.gz txr-13bba10fb47fa1b3638021120042641464f0c57a.tar.bz2 txr-13bba10fb47fa1b3638021120042641464f0c57a.zip |
digits/digpow: recycle temporary conses.
* arith.c (digcommon): Improved termination test in the second
loop to avoid wasteful pop when the list of powers is empty.
Use rcyc_pop to recycle these conses; they will be immediately
reused for building the output list.
-rw-r--r-- | arith.c | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -3729,7 +3729,7 @@ static val digcommon(int pow, val self, val n, val base_in) { val k = r; - val p = nil, p0; + val p = nil; list_collect_decl (out, ptail); while (le(k, n)) { @@ -3737,7 +3737,8 @@ static val digcommon(int pow, val self, val n, val base_in) k = mul(k, r); } - while ((p0 = pop(&p))) { + while (p) { + val p0 = rcyc_pop(&p); cnum i = 0; while (ge(n, p0)) { i++; |