Skip to content

Commit

Permalink
Make List.roll(*) about 1.5x faster
Browse files Browse the repository at this point in the history
- also eliminate R:I.Roller: there are  no clients for that anymore
  • Loading branch information
lizmat committed Jul 22, 2017
1 parent fb7ecb6 commit b147217
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
6 changes: 4 additions & 2 deletions src/core/List.pm
Expand Up @@ -1005,8 +1005,10 @@ my class List does Iterable does Positional { # declared in BOOTSTRAP
self.is-lazy,
X::Cannot::Lazy.new(:action('.roll from')).throw,
Seq.new(nqp::if(
self.elems,
Rakudo::Iterator.Roller(self),
(my $elems := self.elems),
Rakudo::Iterator.Callable( {
nqp::atpos($!reified, $elems.rand.floor)
}, True ),
Rakudo::Iterator.Empty
))
)
Expand Down
7 changes: 0 additions & 7 deletions src/core/Rakudo/Iterator.pm
Expand Up @@ -2681,13 +2681,6 @@ class Rakudo::Iterator {
}.new(&body,&cond)
}

# Return a lazy iterator that keeps calling .roll on the given object.
# Basically the functionality of List.roll(*), but could be on any
# object that has a .roll method.
method Roller(\source) {
Rakudo::Iterator.Callable( { source.roll }, True )
}

# Return an iterator that rotorizes the given iterator with the
# given cycle. If the cycle is a Cool, then it is assumed to
# be a single Int value to R:It.Batch with. Otherwise it is
Expand Down

0 comments on commit b147217

Please sign in to comment.