Skip to content

Commit

Permalink
Make .lines quite a bit faster
Browse files Browse the repository at this point in the history
Especially the Cool variants.  Mostly by making them share the same
proto and getting rid of the |c signature.
  • Loading branch information
lizmat committed Sep 30, 2019
1 parent 519cfde commit 25abfe2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/core.c/Cool.pm6
Expand Up @@ -309,7 +309,11 @@ my class Cool { # declared in BOOTSTRAP
self.Str.comb($pattern, $limit, :$match)
}

method lines(Cool:D: |c) { self.Str.lines(|c) }
proto method lines(|) {*}
multi method lines(Cool:D:) { self.Str.lines }
multi method lines(Cool:D: :$count! ) { self.Str.lines(:$count) }
multi method lines(Cool:D: $limit ) { self.Str.lines($limit) }

method words(Cool:D: |c) { self.Str.words(|c) }

method subst(|c) {
Expand Down
1 change: 0 additions & 1 deletion src/core.c/Str.pm6
Expand Up @@ -1334,7 +1334,6 @@ my class Str does Stringy { # declared in BOOTSTRAP
}
#?endif

proto method lines(|) {*}
multi method lines(Str:D: :$count! --> Int:D) {
# we should probably deprecate this feature
$count ?? self.lines.elems !! self.lines;
Expand Down

0 comments on commit 25abfe2

Please sign in to comment.