Skip to content

Commit

Permalink
Another fairly notable performance boost for reductions (maybe anothe…
Browse files Browse the repository at this point in the history
…r factor of two or so). [+] 1..100000 now runs in about the same time that [+] 1..1000 used to.
  • Loading branch information
jnthn committed Feb 12, 2012
1 parent cd5136e commit 29f5cf7
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/core/metaops.pm
Expand Up @@ -64,10 +64,11 @@ sub METAOP_REDUCE(\$op, :$triangle) {
return $op() unless @values.gimme(1);
my $result := @values.shift;
return $op($result) unless @values.gimme(1);
while @values.gimme(1000) {
my int $i = 0;
my int $i;
while my int $c = @values.gimme(1000) {
$i = 0;
$result := $op($result, @values.shift)
while ($i = $i + 1) < 1000 && @values.gimme(1);
while ($i = $i + 1) <= $c;
}
$result;
})
Expand All @@ -90,10 +91,11 @@ sub METAOP_REDUCE_RIGHT(\$op, :$triangle) {
return $op() unless $list.gimme(1);
my $result := $list.shift;
return $op($result) unless $list.gimme(1);
while $list.gimme(1000) {
my int $i = 0;
my int $i;
while my int $c = $list.gimme(1000) {
$i = 0;
$result := $op($list.shift, $result)
while ($i = $i + 1) < 1000 && $list.gimme(1);
while ($i = $i + 1) <= $c;
}
$result;
}
Expand Down

0 comments on commit 29f5cf7

Please sign in to comment.