Skip to content

Commit

Permalink
lowering: avoid calling a generated function to make new IR just for …
Browse files Browse the repository at this point in the history
…the side-effect of calling diff_names for kwarg error checking (#52081)

empirically this makes a very minor difference, but it seems to be at
least very slightly more optimal in bytes allocated for some tests,
though I didn't check very many tests to compare broadly
```
show         (6) |    15.72 |   0.18 |  1.1 |    2695.53 |   696.03
show         (6) |    15.82 |   0.18 |  1.2 |    2734.35 |   707.94
```
  • Loading branch information
vtjnash authored Nov 10, 2023
1 parent 0513228 commit 786caaa
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/julia-syntax.scm
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@
sparams))
(kw (gensy))
(kwdecl `(|::| ,kw (core NamedTuple)))
(rkw (if (null? restkw) (make-ssavalue) (symbol (string (car restkw) "..."))))
(rkw (if (null? restkw) '() (symbol (string (car restkw) "..."))))
(restkw (map (lambda (v) `(|::| ,v (call (top pairs) (core NamedTuple)))) restkw))
(mangled (let ((und (and name (undot-name name))))
(symbol (string (if (and name (= (string.char (string name) 0) #\#))
Expand Down Expand Up @@ -608,16 +608,18 @@
,tempslot)))
vars vals)
`(block
(= ,rkw (call (top pairs)
,(if (null? keynames)
kw
`(call (top structdiff) ,kw (curly (core NamedTuple)
(tuple ,@(map quotify keynames)))))))
,@(if (null? restkw)
`((if (call (top isempty) ,rkw)
,(if (null? restkw)
`(if (call (top isempty)
(call (top diff_names)
(call (top keys) ,kw)
(tuple ,@(map quotify keynames))))
(null)
(call (top kwerr) ,kw ,@(map arg-name pargl) ,@splatted-vararg)))
'())
(call (top kwerr) ,kw ,@(map arg-name pargl) ,@splatted-vararg))
`(= ,rkw (call (top pairs)
,(if (null? keynames)
kw
`(call (top structdiff) ,kw (curly (core NamedTuple)
(tuple ,@(map quotify keynames))))))))
(return (call ,mangled ;; finally, call the core function
,@keyvars
,@(if (null? restkw) '() (list rkw))
Expand Down

0 comments on commit 786caaa

Please sign in to comment.