From 9770c1aa15fff0f54df2af0291be2c07c0de486e Mon Sep 17 00:00:00 2001 From: Elizabeth Mattijsen Date: Mon, 4 Mar 2019 15:08:02 +0100 Subject: [PATCH] Make say(\x) about 8% faster Adaptation of https://github.com/rakudo/rakudo/pull/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`. --- src/core/io_operators.pm6 | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/core/io_operators.pm6 b/src/core/io_operators.pm6 index 8d483f9c412..2405baac24c 100644 --- a/src/core/io_operators.pm6 +++ b/src/core/io_operators.pm6 @@ -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;