From ba6b84bd0c0b095bfd1dda488e4ef0271605a5df Mon Sep 17 00:00:00 2001 From: Zoffix Znet Date: Fri, 16 Feb 2018 06:15:40 -0500 Subject: [PATCH] Make Str.perl 43x faster for some chars Those that give +uniprop($ord,'Canonical_Combining_Class') > 0 in particular. The change from lower-case hex to upper-case hex is intentional. I think it doesn't matter much. We could also skip the hexafication of ords and simply use the `\c[]` escape, but perhaps decimal character codes are less familiar to humans reading the output? --- src/core/Rakudo/Internals.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/Rakudo/Internals.pm b/src/core/Rakudo/Internals.pm index 45a7745e251..259e7ccd07b 100644 --- a/src/core/Rakudo/Internals.pm +++ b/src/core/Rakudo/Internals.pm @@ -722,10 +722,10 @@ my class Rakudo::Internals { method PERLIFY-STR(Str \string) { sub char-to-escapes(Str $char) { #?if moar - '\x[' ~ $char.NFC.list.map({ .fmt('%0x') }).join(',') ~ ']' + '\x[' ~ $char.NFC.list.map({.base: 16}).join(',') ~ ']' #?endif #?if !moar - $char.ord.fmt('\x[%x]') + '\x[' ~ $char.ord.base(16) ~ ']' #?endif }