From 3e2cfb4d3e885e96d3138232ec56d60bfba6d4f7 Mon Sep 17 00:00:00 2001 From: Daniel Green Date: Wed, 6 Nov 2019 19:09:33 -0500 Subject: [PATCH] Only pass on capture in `sub split` if it's there Otherwise spesh can't intern the callsite and then the jit bails. Other attempts (i.e., adding a new `multi sub split($pat, Cool:D $target)`, or adding that and also changing the `|c` in the other multi to `*%h`) caused errors like `Unexpected named argument 'v' passed` and `Ambiguous call to 'split(Str, Str, :v)'; these signatures all match::($pat, Cool:D $target):($pat, Cool:D $target, *%h)`. Found when playing around with the code referenced in #3281 and makes it slightly faster. --- src/core.c/Cool.pm6 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core.c/Cool.pm6 b/src/core.c/Cool.pm6 index 1b7f3605ec6..fdfa28d3fec 100644 --- a/src/core.c/Cool.pm6 +++ b/src/core.c/Cool.pm6 @@ -492,7 +492,7 @@ proto sub samecase($, $, *%) {*} multi sub samecase(Cool:D $string, Cool:D $pattern) { $string.samecase($pattern) } proto sub split($, $, |) {*} -multi sub split($pat, Cool:D $target, |c) { $target.split($pat, |c) } +multi sub split($pat, Cool:D $target, |c) { c ?? $target.split($pat, |c) !! $target.split($pat) } proto sub chars($, *%) is pure {*} multi sub chars(Cool $x) { $x.Str.chars }