From f6946d73027e1f3213336a6fd721f4ab85036664 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Thu, 8 Sep 2016 06:44:00 -0700 Subject: Optimize qref and sys:rslot using slet. * share/txr/stdlib/struct.tl (qref): Use slet instead of let in expansion so that in the common case of var.(method ...) the expansion simply produces a form with var evaluated in two places. (sys:rslot): Use slet instead of rlet. * tests/012/struct.tl: Update qref expansion test-cases to test for the now simpler expansions. --- share/txr/stdlib/struct.tl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'share') diff --git a/share/txr/stdlib/struct.tl b/share/txr/stdlib/struct.tl index 9b37ae0b..0f3d79eb 100644 --- a/share/txr/stdlib/struct.tl +++ b/share/txr/stdlib/struct.tl @@ -196,11 +196,11 @@ (if (eq dw 'dwim) ^(qref [(slot ,obj ',sym) ,*args] ,*more) :)) (((sym . args)) (let ((osym (gensym))) - ^(let ((,osym ,obj)) + ^(slet ((,osym ,obj)) (call (slot ,osym ',sym) ,osym ,*args)))) (((sym . args) . more) (let ((osym (gensym))) - ^(qref (let ((,osym ,obj)) + ^(qref (slet ((,osym ,obj)) (call (slot ,osym ',sym) ,osym ,*args)) ,*more))) ((sym) ^(slot ,obj ',sym)) ((sym . more) ^(qref (slot ,obj ',sym) ,*more)) @@ -270,7 +270,7 @@ (defplace (sys:rslot struct sym meth-sym) body (getter setter (with-gensyms (struct-sym slot-sym meth-sym) - ^(rlet ((,struct-sym ,struct) + ^(slet ((,struct-sym ,struct) (,slot-sym ,sym) (,meth-sym ,meth-sym)) (macrolet ((,getter () ^(slot ,',struct-sym ,',slot-sym)) -- cgit v1.2.3