Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Remove almost all push-exactly implementations
See 99cd58b for more background on this removal
  • Loading branch information
lizmat committed Mar 18, 2016
1 parent 99cd58b commit 6d120ca
Show file tree
Hide file tree
Showing 6 changed files with 0 additions and 344 deletions.
162 changes: 0 additions & 162 deletions src/core/Any-iterable-methods.pm
Expand Up @@ -324,19 +324,6 @@ Did you mean to add a stub (\{...\}) or did you mean to .classify?"
?? IterationEnd
!! nqp::p6box_i($!index = $!index + 1)
}
method push-exactly($target, int $n) {
my int $done;
while $done < $n {
return IterationEnd
if IterationEnd =:= ($_ := $!iter.pull-one);
$!index = $!index + 1;
if $!test($_) {
$target.push(nqp::p6box_i($!index));
$done = $done + 1;
}
}
$done
}
method push-all($target) {
until ($_ := $!iter.pull-one) =:= IterationEnd {
$!index = $!index + 1;
Expand Down Expand Up @@ -378,31 +365,6 @@ Did you mean to add a stub (\{...\}) or did you mean to .classify?"
}
}
}
method push-exactly($target, int $n) {
my int $done;
my $no-sink;
if $!value.DEFINITE {
$no-sink := $target.push($!value);
$!value := Mu;
$done = $done + 1;
}
while $done < $n {
return IterationEnd
if IterationEnd =:= ($_ := $!iter.pull-one);
$!index = $!index + 1;
if $!test($_) {
$target.push(nqp::p6box_i($!index));
if ($done = $done + 1) < $n {
$no-sink := $target.push($_);
$done = $done + 1;
}
else {
$!value := $_;
}
}
}
$done
}
method push-all($target) {
my $no-sink;
until ($_ := $!iter.pull-one) =:= IterationEnd {
Expand Down Expand Up @@ -435,19 +397,6 @@ Did you mean to add a stub (\{...\}) or did you mean to .classify?"
?? IterationEnd
!! Pair.new($!index = $!index + 1,$_)
}
method push-exactly($target, int $n) {
my int $done;
while $done < $n {
return IterationEnd
if IterationEnd =:= ($_ := $!iter.pull-one);
$!index = $!index + 1;
if $!test($_) {
$target.push(Pair.new($!index,$_));
$done = $done + 1;
}
}
$done
}
method push-all($target) {
until ($_ := $!iter.pull-one) =:= IterationEnd {
$!index = $!index + 1;
Expand Down Expand Up @@ -475,19 +424,6 @@ Did you mean to add a stub (\{...\}) or did you mean to .classify?"
|| $_.match($!test);
$_
}
method push-exactly($target, int $n) {
my int $done;
my $no-sink;
while $done < $n {
return IterationEnd
if IterationEnd =:= ($_ := $!iter.pull-one);
if $_.match($!test) {
$no-sink := $target.push($_);
$done = $done + 1;
}
}
$done
}
method push-all($target) {
my $no-sink;
$no-sink := $target.push($_) if $_.match($!test)
Expand All @@ -506,19 +442,6 @@ Did you mean to add a stub (\{...\}) or did you mean to .classify?"
|| $!test($_);
$_
}
method push-exactly($target, int $n) {
my int $done;
my $no-sink;
while $done < $n {
return IterationEnd
if IterationEnd =:= ($_ := $!iter.pull-one);
if $!test($_) {
$no-sink := $target.push($_);
$done = $done + 1;
}
}
$done
}
method push-all($target) {
my $no-sink;
$no-sink := $target.push($_) if $!test($_)
Expand Down Expand Up @@ -563,19 +486,6 @@ Did you mean to add a stub (\{...\}) or did you mean to .classify?"
|| $!test.ACCEPTS($_);
$_
}
method push-exactly($target, int $n) {
my int $done;
my $no-sink;
while $done < $n {
return IterationEnd
if IterationEnd =:= ($_ := $!iter.pull-one);
if $!test.ACCEPTS($_) {
$no-sink := $target.push($_);
$done = $done + 1;
}
}
$done
}
method push-all($target) {
my $no-sink;
$no-sink := $target.push($_) if $!test.ACCEPTS($_)
Expand Down Expand Up @@ -990,23 +900,6 @@ Did you mean to add a stub (\{...\}) or did you mean to .classify?"
}
IterationEnd
}
method push-exactly($target, int $n) {
my Mu $value;
my str $needle;
my int $done;
my $no-sink;
while $done < $n {
return IterationEnd
if IterationEnd =:= ($value := $!iter.pull-one);
$needle = nqp::unbox_s($value.WHICH);
unless nqp::existskey($!seen, $needle) {
nqp::bindkey($!seen, $needle, 1);
$no-sink := $target.push($value);
$done = $done + 1;
}
}
$done
}
method push-all($target) {
my Mu $value;
my str $needle;
Expand Down Expand Up @@ -1056,23 +949,6 @@ Did you mean to add a stub (\{...\}) or did you mean to .classify?"
}
IterationEnd
}
method push-exactly($target, int $n) {
my Mu $value;
my str $needle;
my int $done;
my $no-sink;
while $done < $n {
return IterationEnd
if IterationEnd =:= ($value := $!iter.pull-one);
$needle = nqp::unbox_s(&!as($value).WHICH);
unless nqp::existskey($!seen, $needle) {
nqp::bindkey($!seen, $needle, 1);
$no-sink := $target.push($value);
$done = $done + 1;
}
}
$done
}
method push-all($target) {
my Mu $value;
my str $needle;
Expand Down Expand Up @@ -1124,25 +1000,6 @@ Did you mean to add a stub (\{...\}) or did you mean to .classify?"
}
IterationEnd
}
method push-exactly($target, int $n) {
my Mu $value;
my str $needle;
my int $done;
my $no-sink;
while $done < $n {
return IterationEnd
if IterationEnd =:= ($value := $!iter.pull-one);
$needle = nqp::unbox_s($value.WHICH);
if nqp::existskey($!seen, $needle) {
$no-sink := $target.push($value);
$done = $done + 1;
}
else {
nqp::bindkey($!seen, $needle, 1);
}
}
$done
}
method push-all($target) {
my Mu $value;
my str $needle;
Expand Down Expand Up @@ -1189,25 +1046,6 @@ Did you mean to add a stub (\{...\}) or did you mean to .classify?"
}
IterationEnd
}
method push-exactly($target, int $n) {
my Mu $value;
my str $needle;
my int $done;
my $no-sink;
while $done < $n {
return IterationEnd
if IterationEnd =:= ($value := $!iter.pull-one);
$needle = nqp::unbox_s(&!as($value).WHICH);
if nqp::existskey($!seen, $needle) {
$no-sink := $target.push($value);
$done = $done + 1;
}
else {
nqp::bindkey($!seen, $needle, 1);
}
}
$done
}
method push-all($target) {
my Mu $value;
my str $needle;
Expand Down
68 changes: 0 additions & 68 deletions src/core/Baggy.pm
Expand Up @@ -157,17 +157,6 @@ my role Baggy does QuantHash {
?? nqp::iterval(nqp::shift($!iter))
!! IterationEnd
}
method push-exactly($target, int $n) {
my int $done;
my $no-sink;
while $done < $n {
return IterationEnd unless $!iter;
$no-sink :=
$target.push(nqp::iterval(nqp::shift($!iter)));
$done = $done + 1;
}
$done
}
method push-all($target) {
my $no-sink;
$no-sink := $target.push(nqp::iterval(nqp::shift($!iter)))
Expand All @@ -183,17 +172,6 @@ my role Baggy does QuantHash {
?? nqp::iterval(nqp::shift($!iter)).key
!! IterationEnd
}
method push-exactly($target, int $n) {
my int $done;
my $no-sink;
while $done < $n {
return IterationEnd unless $!iter;
$no-sink :=
$target.push(nqp::iterval(nqp::shift($!iter)).key);
$done = $done + 1;
}
$done
}
method push-all($target) {
my $no-sink;
$no-sink :=
Expand Down Expand Up @@ -222,30 +200,6 @@ my role Baggy does QuantHash {
IterationEnd
}
}
method push-exactly($target, int $n) {
my int $done;
my $no-sink;
if $!value.DEFINITE {
$no-sink := $target.push($!value);
$!value := Mu;
$done = $done + 1;
}
while $done < $n {
return IterationEnd unless $!iter;
my \tmp =
nqp::decont(nqp::iterval(nqp::shift($!iter)));
$no-sink := $target.push(nqp::getattr(tmp,Pair,'$!key'));
if ($done = $done + 1) < $n {
$no-sink :=
$target.push(nqp::getattr(tmp,Pair,'$!value'));
$done = $done + 1;
}
else {
$!value := nqp::getattr(tmp,Pair,'$!value');
}
}
$done
}
method push-all($target) {
my $no-sink;
while $!iter {
Expand All @@ -266,17 +220,6 @@ my role Baggy does QuantHash {
nqp::iterval(nqp::shift($!iter))),Pair,'$!value')
!! IterationEnd
}
method push-exactly($target, int $n) {
my int $done;
my $no-sink;
while $done < $n {
return IterationEnd unless $!iter;
$no-sink := $target.push(nqp::getattr(nqp::decont(
nqp::iterval(nqp::shift($!iter))),Pair,'$!value'));
$done = $done + 1;
}
$done
}
method push-all($target) {
my $no-sink;
$no-sink := $target.push(nqp::getattr(nqp::decont(
Expand All @@ -297,17 +240,6 @@ my role Baggy does QuantHash {
IterationEnd
}
}
method push-exactly($target, int $n) {
my int $done;
my $no-sink;
while $done < $n {
return IterationEnd unless $!iter;
my \tmp = nqp::iterval(nqp::shift($!iter));
$no-sink := $target.push(Pair.new(tmp.value, tmp.key));
$done = $done + 1;
}
IterationEnd
}
method push-all($target) {
my $no-sink;
while $!iter {
Expand Down
30 changes: 0 additions & 30 deletions src/core/Range.pm
Expand Up @@ -114,21 +114,6 @@ my class Range is Cool does Iterable does Positional {
method pull-one() {
( $!i = $!i + 1 ) <= $!n ?? $!i !! IterationEnd
}
method push-exactly($target, int $n) {
my int $left = $!n - $!i - 1;
if $n > $left {
$target.push(nqp::p6box_i($!i))
while ($!i = $!i + 1) <= $!n;
IterationEnd
}
else {
my int $end = $!i + 1 + $n;
$target.push(nqp::p6box_i($!i))
while ($!i = $!i + 1) < $end;
$!i = $!i - 1; # did one too many
$n
}
}
method push-all($target) {
my int $i = $!i;
my int $n = $!n;
Expand Down Expand Up @@ -285,21 +270,6 @@ my class Range is Cool does Iterable does Positional {
method pull-one() {
( $!i = $!i - 1 ) >= $!n ?? $!i !! IterationEnd
}
method push-exactly($target, int $n) {
my int $left = $!i - $!n - 1;
if $n > $left {
$target.push(nqp::p6box_i($!i))
while ($!i = $!i - 1) >= $!n;
IterationEnd
}
else {
my int $end = $!i - 1 - $n;
$target.push(nqp::p6box_i($!i))
while ($!i = $!i - 1) > $end;
$!i = $!i + 1; # did one too many
$n
}
}
method push-all($target) {
my int $i = $!i;
my int $n = $!n;
Expand Down

0 comments on commit 6d120ca

Please sign in to comment.