Skip to content

Commit

Permalink
Make Str.raku about 7x as fast
Browse files Browse the repository at this point in the history
- for pure alphanumeric strings
- at about 15% of allocations
- bypassing the char-by-char checks completely
  • Loading branch information
lizmat committed Jan 7, 2020
1 parent 2f94362 commit a4b62fb
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/core.c/Str.pm6
Expand Up @@ -368,8 +368,12 @@ my class Str does Stringy { # declared in BOOTSTRAP
multi method gist(Str:D: --> Str:D) { self }
multi method raku(Str:D: --> Str:D) {
nqp::chars(self)
?? self!rakufy
!! '""'
?? nqp::findnotcclass(
nqp::const::CCLASS_ALPHANUMERIC,self,0,nqp::chars(self)
) == nqp::chars(self)
?? nqp::concat('"',nqp::concat(self,'"')) # fast path alpha
!! self!rakufy # slow path non-alpha
!! '""' # empty string
}

# Special case escape values for rakufication
Expand Down

0 comments on commit a4b62fb

Please sign in to comment.