Skip to content

Commit

Permalink
Make say(\x) about 8% faster
Browse files Browse the repository at this point in the history
Adaptation of #2734 , scovit++ for the
spotting of this opportunity.  Alas, we need to call .gist in the say sub
as we have spectest that depend on `say` calling `.gist` even on `Str`.
  • Loading branch information
lizmat committed Mar 4, 2019
1 parent a8cd286 commit 9770c1a
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/core/io_operators.pm6
Expand Up @@ -10,8 +10,11 @@ multi sub print(**@args is raw) { $*OUT.print: @args.join }
proto sub say(|) {*}
multi sub say() { $*OUT.print-nl }
multi sub say(\x) {
my $out := $*OUT;
$out.print(nqp::concat(nqp::unbox_s(x.gist),$out.nl-out));
nqp::if(
nqp::istype((my $out := $*OUT),IO::Handle),
$out.say(x.gist),
$out.print(nqp::concat(nqp::unbox_s(x.gist),$out.nl-out))
)
}
multi sub say(**@args is raw) {
my str $str;
Expand Down

0 comments on commit 9770c1a

Please sign in to comment.