summaryrefslogtreecommitdiffstats
path: root/share
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2017-10-25 23:52:33 -0700
committerKaz Kylheku <kaz@kylheku.com>2017-10-25 23:52:33 -0700
commitd066056a22bfea38901da258bd039fc4588c8251 (patch)
tree21c0d2ba9327f037947d8d6a7696716a5098831e /share
parentd01991e9b250ca65d9afbfd7e5efd9ed4f0ef923 (diff)
downloadtxr-d066056a22bfea38901da258bd039fc4588c8251.tar.gz
txr-d066056a22bfea38901da258bd039fc4588c8251.tar.bz2
txr-d066056a22bfea38901da258bd039fc4588c8251.zip
awk: retrieve range flag vector once per iteration.
This is an improvement in the code generation related to awk range expressions. Previously, on each iteration, for each range expression, the awk state structure is accessed to retrieve the flag vector, which is then kept in a lexical variable. With this change, the retrieval is done once for all the range expressions, which share the same variable to access it. * share/txr/stdlib/awk.tl (sys:awk-compile-time): New slot, rng-vec-temp. (sys:awk-mac-let): Alias the flag variable to a simplified vecref expression which accesses the vector assumed to have been retrieved and bound to the variable named by the rng-vec-temp gensym. (awk): Add one more variable binding into the scope of the ranges: the binding of the variable named by the rng-vec-temp gensym, to an expression which retrieves the rng-vec from the Awk run-time state structure.
Diffstat (limited to 'share')
-rw-r--r--share/txr/stdlib/awk.tl10
1 files changed, 6 insertions, 4 deletions
diff --git a/share/txr/stdlib/awk.tl b/share/txr/stdlib/awk.tl
index 57e7c271..88509ccd 100644
--- a/share/txr/stdlib/awk.tl
+++ b/share/txr/stdlib/awk.tl
@@ -61,6 +61,7 @@
cond-actions
(nranges 0)
(rng-rec-temp (gensym))
+ (rng-vec-temp (gensym))
rng-expr-temps
rng-exprs
outer-env)
@@ -334,7 +335,7 @@
(set-diff te-ef te-ff)
'functions)
(push rng-temp (qref ,awc rng-expr-temps))
- (push ^(placelet ((flag (vecref (qref ,',aws-sym rng-vec) ,ix)))
+ (push ^(placelet ((flag (vecref ,(qref ,awc rng-vec-temp) ,ix)))
(let ((,flag-old flag) ,flag-act ,flag-deact
,*(if need-mid ^(,flag-mid (,from-expr-val ,from-expr-ex))))
,*(if need-mid
@@ -474,9 +475,10 @@
^((,awk-fun (lambda (,aws-sym)
,(if awc.rng-exprs
^(let* ((,awc.rng-rec-temp rec)
- ,*(nreverse
- (zip awc.rng-expr-temps
- awc.rng-exprs)))
+ (,awc.rng-vec-temp (qref ,aws-sym rng-vec))
+ ,*(nreverse
+ (zip awc.rng-expr-temps
+ awc.rng-exprs)))
,p-actions-xform)
p-actions-xform))))))
,*awc.begin-actions