Skip to content

Commit cc6159a

Browse files
authored
Optimize _ pattern in syntax-case clauses (#728)
Avoid emitting a call to $syntax-dispatch for _ patterns and emit () instead. This allow cp0 optimizations for such patterns.
1 parent 629afef commit cc6159a

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

LOG

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2455,3 +2455,5 @@
24552455
boot/*/scheme.h c/externs.h c/number.c c/scheme.c csug/foreign.stex
24562456
mats/foreign1.c mats/foreign.ms release_notes/release_notes.stex
24572457
s/mkheader.ss
2458+
- optimize simple _ patterns in syntax-case
2459+
s/syntax.ss

s/syntax.ss

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6423,12 +6423,16 @@
64236423
(let ([y (gen-var 'tmp)])
64246424
(build-let no-source
64256425
(list y)
6426-
(list (if (eq? p 'any)
6427-
(build-primcall no-source 3 'list
6428-
(build-lexical-reference no-source x))
6429-
(build-primcall no-source 3 '$syntax-dispatch
6430-
(build-lexical-reference no-source x)
6431-
(build-data no-source p))))
6426+
(list (cond
6427+
[(eq? p 'any)
6428+
(build-primcall no-source 3 'list
6429+
(build-lexical-reference no-source x))]
6430+
[(eq? p '_)
6431+
(build-data no-source '())]
6432+
[else
6433+
(build-primcall no-source 3 '$syntax-dispatch
6434+
(build-lexical-reference no-source x)
6435+
(build-data no-source p))]))
64326436
(let-syntax ([y (identifier-syntax
64336437
(build-lexical-reference no-source y))])
64346438
(build-conditional no-source

0 commit comments

Comments
 (0)