Skip to content

Commit

Permalink
Make .words 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 25abfe2 commit 1e2b0ec
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/core.c/Cool.pm6
Expand Up @@ -314,7 +314,9 @@ my class Cool { # declared in BOOTSTRAP
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) }
proto method words(|) {*}
multi method words(Cool:D:) { self.Str.words }
multi method words(Cool:D: $limit ) { self.Str.words($limit) }

method subst(|c) {
$/ := nqp::getlexcaller('$/');
Expand Down
1 change: 0 additions & 1 deletion src/core.c/Str.pm6
Expand Up @@ -2216,7 +2216,6 @@ my class Str does Stringy { # declared in BOOTSTRAP
nqp::islt_i($pos, $left) ?? '' !! nqp::p6box_s(nqp::substr($str, $left, $pos + 1 - $left));
}

proto method words(|) {*}
multi method words(Str:D: $limit --> Seq:D) {
nqp::istype($limit,Whatever) || $limit == Inf
?? self.words
Expand Down

0 comments on commit 1e2b0ec

Please sign in to comment.