Skip to content

Commit

Permalink
Make Str.perl 43x faster for some chars
Browse files Browse the repository at this point in the history
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?
  • Loading branch information
zoffixznet committed Feb 16, 2018
1 parent 8b7385d commit ba6b84b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/core/Rakudo/Internals.pm
Expand Up @@ -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
}

Expand Down

0 comments on commit ba6b84b

Please sign in to comment.