Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
just do a straight eager rpa write, 10% faster
No point in involving gather/take at all when we know this is eager.
Could probably speed this up further if we had low-level memory copying
of rpa pointer data, so we could batch the memory initialization.

Actually, this runs 10% faster on Moar, but a little slower on JVM than
previous.  We'll optimize for the better optimizer at this point, which
is Moar's.  Presumably the JVM's optimizer will catch up sooner or later.
  • Loading branch information
TimToady committed Aug 19, 2014
1 parent 1a7f85b commit 18429d5
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions src/core/List.pm
Expand Up @@ -635,20 +635,17 @@ multi infix:<xx>(Mu \x, Whatever, :$thunked!) {
multi infix:<xx>(Mu \x, Whatever) {
GatherIter.new({ loop { take x } }, :infinite(True)).flat
}
multi infix:<xx>(Mu \x, $n is copy) {
$n = $n.Int;
if $n <= 10 {
GatherIter.new({ take x while --$n >= 0; }).flat
}
else {
my \size = floor sqrt($n);
my \batch := infix:<xx>(x, size);
GatherIter.new({
take batch while ($n -= size) >= 0;
$n += size; # make up for extra -=
take batch[0 ..^ $n] if $n;
}).flat
}
multi infix:<xx>(Mu \x, $n) {
my int $size = $n.Int;

my Mu $rpa := nqp::list();
nqp::setelems($rpa, $size);
nqp::setelems($rpa, 0);

$size = $size + 1;
nqp::push($rpa,x) while $size = $size - 1;

nqp::p6parcel($rpa, Any);
}

proto sub pop(@) {*}
Expand Down

0 comments on commit 18429d5

Please sign in to comment.