Skip to content

Commit

Permalink
Simply pass on limit in Str.lines/words
Browse files Browse the repository at this point in the history
The extra check was not really necessary, as Masterduke++ pointed out
  • Loading branch information
lizmat committed May 24, 2020
1 parent 96c3c53 commit 9942ccc
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions src/core.c/Str.pm6
Original file line number Diff line number Diff line change
Expand Up @@ -1833,14 +1833,10 @@ my class Str does Stringy { # declared in BOOTSTRAP
$count ?? self.lines.elems !! self.lines;
}
multi method lines(Str:D: $limit --> Seq:D) {
nqp::istype($limit,Whatever) || $limit == Inf
?? self.lines
!! self.lines.head($limit)
self.lines.head($limit)
}
multi method lines(Str:D: $limit, Bool :$chomp! --> Seq:D) {
nqp::istype($limit,Whatever) || $limit == Inf
?? self.lines(:$chomp)
!! self.lines(:$chomp).head($limit)
self.lines(:$chomp).head($limit)
}

my class Lines does PredictiveIterator {
Expand Down Expand Up @@ -2861,9 +2857,7 @@ my class Str does Stringy { # declared in BOOTSTRAP
}

multi method words(Str:D: $limit --> Seq:D) {
nqp::istype($limit,Whatever) || $limit == Inf
?? self.words
!! self.words.head($limit)
self.words.head($limit)
}
my class Words does PredictiveIterator {
has str $!str;
Expand Down

0 comments on commit 9942ccc

Please sign in to comment.