Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Couple of small optimizations in lists.
  • Loading branch information
jnthn committed Oct 1, 2011
1 parent d655c14 commit e32b7c2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/core/List.pm
Expand Up @@ -71,7 +71,7 @@ my class List does Positional {

# loop through iterators until we have at least $n elements
my $count = nqp::p6box_i(nqp::elems($!items));
my $eager = Whatever.ACCEPTS($n);
my $eager = nqp::p6bool(nqp::istype($n, Whatever));
while $!nextiter.defined && ($eager
?? !$!nextiter.infinite
!! ($count < $n)) {
Expand Down Expand Up @@ -323,7 +323,7 @@ proto infix:<xx>(|$) { * }
multi infix:<xx>() { fail "No zero-arg meaning for infix:<xx>" }
multi infix:<xx>(Mu \$x) { $x }
multi infix:<xx>(Mu \$x, $n is copy) {
$n = $Inf if Whatever.ACCEPTS($n);
$n = $Inf if nqp::p6bool(nqp::istype($n, Whatever));
GatherIter.new({ take $x while $n-- > 0; }, :infinite($n == $Inf)).list
}

Expand Down
2 changes: 1 addition & 1 deletion src/core/ListIter.pm
Expand Up @@ -9,7 +9,7 @@ my class ListIter {

method reify($n = 1, :$sink) {
if !$!reified.defined {
my $eager = Whatever.ACCEPTS($n);
my $eager = nqp::p6bool(nqp::istype($n, Whatever));
my $flattens = $!list.defined && $!list.flattens;
my $count = $eager ?? 100000 !! $n.Int;
my $rpa := nqp::list();
Expand Down

0 comments on commit e32b7c2

Please sign in to comment.