Skip to content

Instantly share code, notes, and snippets.

@lizmat
Created May 10, 2016 10:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lizmat/b312048a759328a8ecdb8c215df66e1d to your computer and use it in GitHub Desktop.
Save lizmat/b312048a759328a8ecdb8c215df66e1d to your computer and use it in GitHub Desktop.
diff --git a/src/core/Iterable.pm b/src/core/Iterable.pm
index b8f070a..5a8f888 100644
--- a/src/core/Iterable.pm
+++ b/src/core/Iterable.pm
@@ -48,16 +48,13 @@ my role Iterable {
}
method push-all($target) {
my $got;
- until ($got := $!source.pull-one) =:= IterationEnd {
- if nqp::istype($got, Iterable) && !nqp::iscont($got) {
- my $nested := $got.flat.iterator;
- $target.push($got)
- until ($got := $nested.pull-one) =:= IterationEnd;
- }
- else {
- $target.push($got);
- }
- }
+ my $nested;
+ nqp::istype($got,Iterable) && !nqp::iscont($got)
+ ?? STATEMENT_LIST(
+ $nested := $got.flat.iterator;
+ $target.push($got) until ($got := $nested.pull-one) =:= IterationEnd)
+ !! $target.push($got)
+ until ($got := $!source.pull-one) =:= IterationEnd;
IterationEnd
}
method count-only() {
@@ -66,11 +63,11 @@ my role Iterable {
until ($got := $!source.pull-one) =:= IterationEnd {
if nqp::istype($got, Iterable) && !nqp::iscont($got) {
my $nested := $got.flat.iterator;
- $found = $found + 1
+ ++$found
until ($got := $nested.pull-one) =:= IterationEnd;
}
else {
- $found = $found + 1;
+ ++$found
}
}
nqp::p6box_i($found)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment