Skip to content

Commit

Permalink
Optimize _ pattern in syntax-case clauses (#728)
Browse files Browse the repository at this point in the history
Avoid emitting a call to $syntax-dispatch for _ patterns and emit ()
instead. This allow cp0 optimizations for such patterns.
  • Loading branch information
Jarhmander authored Oct 16, 2023
1 parent 629afef commit cc6159a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
2 changes: 2 additions & 0 deletions LOG
Original file line number Diff line number Diff line change
Expand Up @@ -2455,3 +2455,5 @@
boot/*/scheme.h c/externs.h c/number.c c/scheme.c csug/foreign.stex
mats/foreign1.c mats/foreign.ms release_notes/release_notes.stex
s/mkheader.ss
- optimize simple _ patterns in syntax-case
s/syntax.ss
16 changes: 10 additions & 6 deletions s/syntax.ss
Original file line number Diff line number Diff line change
Expand Up @@ -6423,12 +6423,16 @@
(let ([y (gen-var 'tmp)])
(build-let no-source
(list y)
(list (if (eq? p 'any)
(build-primcall no-source 3 'list
(build-lexical-reference no-source x))
(build-primcall no-source 3 '$syntax-dispatch
(build-lexical-reference no-source x)
(build-data no-source p))))
(list (cond
[(eq? p 'any)
(build-primcall no-source 3 'list
(build-lexical-reference no-source x))]
[(eq? p '_)
(build-data no-source '())]
[else
(build-primcall no-source 3 '$syntax-dispatch
(build-lexical-reference no-source x)
(build-data no-source p))]))
(let-syntax ([y (identifier-syntax
(build-lexical-reference no-source y))])
(build-conditional no-source
Expand Down

0 comments on commit cc6159a

Please sign in to comment.