Skip to content

Commit

Permalink
Make IntStr.raku about 2x as fast
Browse files Browse the repository at this point in the history
- use low level concat
- evade .Int, nqp::tostr_I will do the right thing
- evade .Str, just fetch the attribute directly
- at 2/3rds of the number of allocations
  • Loading branch information
lizmat committed Jan 7, 2020
1 parent 960b0a1 commit 2261ef1
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/core.c/allomorphs.pm6
Expand Up @@ -27,7 +27,14 @@ my class IntStr is Int is Str {
method Int(IntStr:D:) { nqp::add_I(self, 0, Int) }
multi method Str(IntStr:D:) { nqp::getattr_s(self, Str, '$!value') }

multi method raku(IntStr:D:) { self.^name ~ '.new(' ~ self.Int.raku ~ ', ' ~ self.Str.raku ~ ')' }
multi method raku(IntStr:D:) {
nqp::concat(self.^name,
nqp::concat('.new(',
nqp::concat(nqp::tostr_I(self),
nqp::concat(', ',
nqp::concat(nqp::getattr_s(self,Str,'$!value').raku,')'
)))))
}
}

my class NumStr is Num is Str {
Expand Down

0 comments on commit 2261ef1

Please sign in to comment.