Skip to content
Permalink
Browse files

Make [42] use the new Scalar initialization setup

Completely inlines `for ^1_000_000 -> int $_ { [42] }` without any
allocations whatsoever: 99.11% of frames got inlined in --profile.
  • Loading branch information...
lizmat committed Sep 27, 2018
1 parent 06dfbf0 commit 8c4546bb58c0a31aa2e229eb871d20ecaec34752
Showing with 7 additions and 4 deletions.
  1. +7 −4 src/core/array_operators.pm6
@@ -44,11 +44,14 @@ multi sub circumfix:<[ ]>(Mu \x) { # really only for [$foo]
nqp::p6bindattrinvres(
nqp::create(Array),List,'$!reified',
nqp::stmts(
nqp::push(
(my $reified := nqp::create(IterationBuffer)),
nqp::assign(nqp::p6scalarfromdesc(nqp::null),x)
(my \scalar := nqp::create(Scalar)),
nqp::bindattr(
scalar, Scalar, '$!descriptor',
BEGIN nqp::getcurhllsym('default_cont_spec')
),
$reified
nqp::bindattr(scalar,Scalar,'$!value',nqp::decont(x)),
nqp::bindpos((my \reified := nqp::create(IterationBuffer)),0,scalar),
reified
)
)
}

0 comments on commit 8c4546b

Please sign in to comment.
You can’t perform that action at this time.