From d30af5639c1a3a27452a7cd63c6f91201eac687b Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Wed, 20 Jan 2021 18:59:57 -0800 Subject: match-case: eliminate useless initial flag test. * share/txr/stdlib/match.tl (match-case): The first case should not test the flag variable, the variable is false. This compiles to a useless if instruction and unreachable code. I tried writing a peephole rule against that instruction sequence in an experimental peephole optimizer, but across the entire code, it only matched in code in compiler.tl arising out of match-case, so it is better to squash this at the source. I won't commit the peephole optimizer until it comes up with something that isn't better fixed elsewhere. --- share/txr/stdlib/match.tl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'share') diff --git a/share/txr/stdlib/match.tl b/share/txr/stdlib/match.tl index 0c672903..ec35e0a9 100644 --- a/share/txr/stdlib/match.tl +++ b/share/txr/stdlib/match.tl @@ -338,9 +338,10 @@ (result (gensym "result-")) (clause-matches [mapcar (op compile-match (car @1) obj) clauses]) (clause-code (collect-each ((cl clauses) - (cm clause-matches)) + (cm clause-matches) + (i 0)) (mac-param-bind *match-form* (match . forms) cl - ^(unless ,flag + ^(unless ,(unless (zerop i) flag) (let (,*cm.(get-vars)) (set ,result ,cm.(wrap-guards ^(progn ,*cm.(assignments) -- cgit v1.2.3