Skip to content

Commit

Permalink
Make Array[Int].raku at least 5% faster
Browse files Browse the repository at this point in the history
- at least one scalar allocation less
- call Type.raku only once
- better optimized at handling "holes" in the array
  • Loading branch information
lizmat committed Jan 8, 2020
1 parent 8ad3d24 commit 66cf6f8
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/core.c/TypedArray.pm6
Expand Up @@ -105,8 +105,11 @@
}

multi method raku(::?CLASS:D \SELF:) {
my $args = self.map({ ($_ // TValue).raku(:arglist) }).join(', ');
'Array[' ~ TValue.raku ~ '].new(' ~ $args ~ ')';
my $type := TValue.raku;
my $raku := self.map({
nqp::isconcrete($_) ?? .raku(:arglist) !! $type
}).join(', ');
'Array[' ~ $type ~ '].new(' ~ $raku ~ ')';
}
}
method ^parameterize(Mu:U \arr, Mu \t, |c) {
Expand Down

0 comments on commit 66cf6f8

Please sign in to comment.