Skip to content

Commit

Permalink
Speed up generated methods of Perl 5 objects
Browse files Browse the repository at this point in the history
Use rakudo's optimized multi dispatcher instead of checking ourselves if
arguments were passed.
  • Loading branch information
niner committed Aug 17, 2017
1 parent 4fca771 commit f52727c
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/Inline/Perl5/Object.pm6
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@ class Inline::Perl5::Object {

method FALLBACK($name, *@args, *%kwargs) {
my $role := Metamodel::ParametricRoleHOW.new_type;
$role.^add_method($name, method (|args) {
args
?? $!perl5.invoke-args($!ptr, $name, args)
!! $!perl5.invoke($!ptr, $name);
$role.^add_multi_method($name, method (|args) {
$!perl5.invoke-args($!ptr, $name, args)
});
$role.^add_multi_method($name, method () {
$!perl5.invoke($!ptr, $name)
});
$role.^set_body_block(-> |args {});
$role.^compose;
Expand Down

0 comments on commit f52727c

Please sign in to comment.