summaryrefslogtreecommitdiffstats
path: root/stdlib/compiler.tl
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2025-06-19 06:41:43 -0700
committerKaz Kylheku <kaz@kylheku.com>2025-06-19 06:41:43 -0700
commit5b9727bbd85793fe9fa280b621ca2af7f25a7417 (patch)
tree17eb9ddc91235453150179e5b80099e20e43ae50 /stdlib/compiler.tl
parentfdbe06cd26523f3ccc7670146a696a88e8c7fb87 (diff)
downloadtxr-5b9727bbd85793fe9fa280b621ca2af7f25a7417.tar.gz
txr-5b9727bbd85793fe9fa280b621ca2af7f25a7417.tar.bz2
txr-5b9727bbd85793fe9fa280b621ca2af7f25a7417.zip
compiler: TCO: redundant code handling optionals.
* stdlib/compiler.tl (compiler comp-tail-call): Throw away the code generated by lambda-apply-transform for doing defaulting of optionals. The function already contains code to do that, right at the top where the tail call jumps. defaulting optionals twice is not just a waste of time, but can evaluate twice the expressions which provide the default values.
Diffstat (limited to 'stdlib/compiler.tl')
-rw-r--r--stdlib/compiler.tl13
1 files changed, 5 insertions, 8 deletions
diff --git a/stdlib/compiler.tl b/stdlib/compiler.tl
index fc0e9140..37c5df56 100644
--- a/stdlib/compiler.tl
+++ b/stdlib/compiler.tl
@@ -1605,17 +1605,14 @@
(args (butlastn 0 (cdr form)))
(dot-arg (nthlast 0 form))
(lat (sys:lambda-apply-transform lamb args dot-arg nil)))
- (match (@(or alet let) @temps (let* @sets . @code)) lat
+ (match (@(or alet let) @temps (let* @sets . @nil)) lat
(let* ((xsets (mapcar (tb ((sym val))
^(sys:setq-in-env ,sym ,val ,tenv))
sets))
- (sfrag me.(comp-let oreg env ^(let ,temps ,*xsets)))
- (cfrag me.(compile oreg tenv (expand ^(progn ,*code)))))
- (set me.tjmp-occurs t)
- (new (frag cfrag.oreg
- (append sfrag.code cfrag.code ^((tjmp ,tfn.label)))
- (uni sfrag.fvars cfrag.fvars)
- (uni sfrag.ffuns cfrag.ffuns)))))))))
+ (sfrag me.(comp-let oreg env ^(let ,temps ,*xsets))))
+ (set me.tjmp-occurs t
+ sfrag.code (append sfrag.code ^((tjmp ,tfn.label))))
+ sfrag))))))
(defmeth compiler comp-for (me oreg env form)
(mac-param-bind form (t inits (: (test nil test-p) . rets) incs . body) form