summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2019-01-30 06:36:39 -0800
committerKaz Kylheku <kaz@kylheku.com>2019-01-30 06:36:39 -0800
commit57e8fb7da3fa0239e43635d6c227ffea33d8a871 (patch)
treefa066df08b1b5f4736236c9cf4ea8796f6946146
parentcbeabe1b2fdc86df466218b2c48d61ab2e5d8fb4 (diff)
downloadtxr-57e8fb7da3fa0239e43635d6c227ffea33d8a871.tar.gz
txr-57e8fb7da3fa0239e43635d6c227ffea33d8a871.tar.bz2
txr-57e8fb7da3fa0239e43635d6c227ffea33d8a871.zip
caseql: generate better code.
* eval.c (me_case): Replace a code generation pattern of the (if (and x y) z) with the equivalent (and x y z). The motivation behind this is that it effectively coaxes a jump-threading optimization out of our simplistic compiler. The failure cases out of a single *and* all jump past the entire code block, whereas with the cascaded if + and we get a double test of the same failed value threading through two branches.
-rw-r--r--eval.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/eval.c b/eval.c
index c35dab1d..2f803a70 100644
--- a/eval.c
+++ b/eval.c
@@ -4027,15 +4027,13 @@ static val me_case(val form, val menv)
return list(let_s, list(list(tformsym, testform, nao),
list(swres, uniq, nao),
nao),
- list(if_s,
- list(and_s,
- list(intern(if3(all_keys_integer,
- lit("integerp"), lit("chrp")),
- user_package),
- tformsym, nao),
- list(intern(lit("<="), user_package),
- minkey, tformsym, maxkey, nao),
- nao),
+ list(and_s,
+ list(intern(if3(all_keys_integer,
+ lit("integerp"), lit("chrp")),
+ user_package),
+ tformsym, nao),
+ list(intern(lit("<="), user_package),
+ minkey, tformsym, maxkey, nao),
list(set_s,
swres,
list(switch_s,