Skip to content

Commit

Permalink
Make Cool.subst a multi and make it pass on quicker
Browse files Browse the repository at this point in the history
By indicating that it needs 2 parameters with optionally nameds.  This
should optimize much better than |c -> |c.
  • Loading branch information
lizmat committed Nov 8, 2019
1 parent a05e169 commit cd4ab4f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 6 additions & 2 deletions src/core.c/Cool.pm6
Expand Up @@ -318,9 +318,13 @@ my class Cool { # declared in BOOTSTRAP
multi method words(Cool:D:) { self.Str.words }
multi method words(Cool:D: $limit ) { self.Str.words($limit) }

method subst(|c) {
proto method subst(|) {
$/ := nqp::getlexcaller('$/');
self.Stringy.subst(|c);
{*}
}
multi method subst(Cool:D: $original, $replacement, *%options) {
$/ := nqp::getlexcaller('$/');
self.Stringy.subst($original, $replacement, |%options);
}

# `$value-to-subst-mutate` will show up in errors when called on non-rw
Expand Down
4 changes: 0 additions & 4 deletions src/core.c/Str.pm6
Expand Up @@ -1175,10 +1175,6 @@ my class Str does Stringy { # declared in BOOTSTRAP
matches))
}

proto method subst(|) {
$/ := nqp::getlexcaller('$/');
{*}
}
multi method subst(Str:D: Str:D $original, Str:D $final, *%options) {
nqp::if(
(my $opts := nqp::getattr(%options,Map,'$!storage'))
Expand Down

0 comments on commit cd4ab4f

Please sign in to comment.