Skip to content

Commit

Permalink
Revert "Restore the CachedIterator role"
Browse files Browse the repository at this point in the history
This reverts commit dfae760.

Alas, not enough time to check this out before the 2021.4 release.
Better luck for the 2021.5 release I hope.
  • Loading branch information
lizmat committed Apr 16, 2021
1 parent 6fdc2b6 commit 46483b8
Show file tree
Hide file tree
Showing 9 changed files with 3 additions and 40 deletions.
8 changes: 0 additions & 8 deletions src/core.c/Iterator.pm6
Expand Up @@ -129,12 +129,4 @@ my role PredictiveIterator does Iterator {
method bool-only(--> Bool:D) { self.count-only.Bool }
}

# The CachedIterator role is a refinement of the PredictiveIterator role for
# those cases where the source of the iterator is a Positional structure that
# supports the AT-POS interface. With such a structure, there is no need to
# build a separate cache for the PositionalBindFailover functionality.
my role CachedIterator does PredictiveIterator {
method cache(--> Positional:D) { ... }
}

# vim: expandtab shiftwidth=4
25 changes: 3 additions & 22 deletions src/core.c/Rakudo/Iterator.pm6
Expand Up @@ -1702,18 +1702,13 @@ class Rakudo::Iterator {

# Returns a sentinel Iterator object that will never generate any value.
# Does not take a parameter.
my class Empty does CachedIterator {
my class Empty does PredictiveIterator {
method new() { nqp::create(self) }
method pull-one(--> IterationEnd) { }
method push-all($ --> IterationEnd) { }
method sink-all(--> IterationEnd) { }
method skip-one(--> 0) { }
method skip-at-least($ --> 0) { }
method cache() {
BEGIN nqp::p6bindattrinvres(
nqp::create(List),List,'$!reified',nqp::create(IterationBuffer)
)
}
method count-only(--> 0) { }
method bool-only(--> False) { }
}
Expand Down Expand Up @@ -3300,7 +3295,7 @@ class Rakudo::Iterator {
# Return an iterator for an Array that has been completely reified
# already. Returns a assignable container for elements don't exist
# before the end of the reified array.
my class ReifiedArrayIterator does CachedIterator {
my class ReifiedArrayIterator does PredictiveIterator {
has $!reified;
has $!descriptor;
has int $!i;
Expand Down Expand Up @@ -3376,13 +3371,6 @@ class Rakudo::Iterator {
)
)
}
method cache() is raw {
nqp::iseq_i($!i,-1)
?? nqp::p6bindattrinvres(
nqp::create(List),List,'$!reified',$!reified
)
!! List.from-iterator(self)
}
method count-only(--> Int:D) {
nqp::elems($!reified) - $!i - nqp::islt_i($!i,nqp::elems($!reified))
}
Expand All @@ -3395,7 +3383,7 @@ class Rakudo::Iterator {
# Return an iterator for a List that has been completely reified
# already. Returns an nqp::null for elements that don't exist
# before the end of the reified list.
my class ReifiedListIterator does CachedIterator {
my class ReifiedListIterator does PredictiveIterator {
has $!reified;
has int $!i;

Expand Down Expand Up @@ -3464,13 +3452,6 @@ class Rakudo::Iterator {
)
)
}
method cache() is raw {
nqp::iseq_i($!i,-1)
?? nqp::p6bindattrinvres(
nqp::create(List),List,'$!reified',$!reified
)
!! List.from-iterator(self)
}
method count-only(--> Int:D) {
nqp::elems($!reified) - $!i - nqp::islt_i($!i,nqp::elems($!reified))
}
Expand Down
4 changes: 0 additions & 4 deletions src/core.c/Seq.pm6
Expand Up @@ -11,10 +11,6 @@ my class Seq is Cool does Iterable does Sequence {
multi method new(Seq: Iterator:D $iter) {
nqp::p6bindattrinvres(nqp::create(self),Seq,'$!iter',nqp::decont($iter))
}
# Special handling for CachedIterators, setting the cache up immediately
multi method new(Seq: CachedIterator:D $iter) {
nqp::p6bindattrinvres(nqp::create(self),Seq,'$!list',$iter.cache)
}
# This candidate exists purely for being able to EVAL a .raku
# representation of a Seq of which the iterator has already been taken,
multi method new(Seq:) { nqp::create(self) }
Expand Down
1 change: 0 additions & 1 deletion t/02-rakudo/03-corekeys-6c.t
Expand Up @@ -501,7 +501,6 @@ my @expected = (
Q{Broken},
Q{Buf},
Q{CX},
Q{CachedIterator},
Q{CallFrame},
Q{Callable},
Q{Cancellation},
Expand Down
1 change: 0 additions & 1 deletion t/02-rakudo/03-corekeys-6d.t
Expand Up @@ -501,7 +501,6 @@ my @expected = (
Q{Broken},
Q{Buf},
Q{CX},
Q{CachedIterator},
Q{CallFrame},
Q{Callable},
Q{Cancellation},
Expand Down
1 change: 0 additions & 1 deletion t/02-rakudo/03-corekeys-6e.t
Expand Up @@ -503,7 +503,6 @@ my @expected = (
Q{Broken},
Q{Buf},
Q{CX},
Q{CachedIterator},
Q{CallFrame},
Q{Callable},
Q{Cancellation},
Expand Down
1 change: 0 additions & 1 deletion t/02-rakudo/03-corekeys.t
Expand Up @@ -504,7 +504,6 @@ my @allowed =
Q{Broken},
Q{Buf},
Q{CX},
Q{CachedIterator},
Q{CallFrame},
Q{Callable},
Q{Cancellation},
Expand Down
1 change: 0 additions & 1 deletion t/02-rakudo/04-settingkeys-6c.t
Expand Up @@ -501,7 +501,6 @@ my %allowed = (
Q{Buf},
Q{CORE-SETTING-REV},
Q{CX},
Q{CachedIterator},
Q{CallFrame},
Q{Callable},
Q{Cancellation},
Expand Down
1 change: 0 additions & 1 deletion t/02-rakudo/04-settingkeys-6e.t
Expand Up @@ -501,7 +501,6 @@ my %allowed = (
Q{Buf},
Q{CORE-SETTING-REV},
Q{CX},
Q{CachedIterator},
Q{CallFrame},
Q{Callable},
Q{Cancellation},
Expand Down

0 comments on commit 46483b8

Please sign in to comment.