Skip to content
Permalink
Browse files

Make for Str.words { } about 3x as fast

- lose the return
- bind to the final result instead of copying the result
- lose a scope
  • Loading branch information...
lizmat committed Sep 4, 2018
1 parent 5b34f69 commit b8f37bfce0184039e2bacaaf70689c408bd71ff3
Showing with 14 additions and 15 deletions.
  1. +14 −15 src/core/Str.pm6
@@ -2157,21 +2157,20 @@ my class Str does Stringy { # declared in BOOTSTRAP
}
method new(\string) { nqp::create(self)!SET-SELF(string) }
method pull-one() {
my int $left;
my int $nextpos;

if ($left = $!chars - $!pos) > 0 {
$nextpos = nqp::findcclass(
nqp::const::CCLASS_WHITESPACE, $!str, $!pos, $left);

my str $found =
nqp::substr($!str, $!pos, $nextpos - $!pos);
$!pos = nqp::findnotcclass( nqp::const::CCLASS_WHITESPACE,
$!str, $nextpos, $!chars - $nextpos);

return nqp::p6box_s($found);
}
IterationEnd
nqp::if(
(my int $left = $!chars - $!pos) > 0,
nqp::stmts(
(my int $nextpos = nqp::findcclass(
nqp::const::CCLASS_WHITESPACE, $!str, $!pos, $left)),
(my $found := nqp::p6box_s(
nqp::substr($!str, $!pos, $nextpos - $!pos)
)),
($!pos = nqp::findnotcclass( nqp::const::CCLASS_WHITESPACE,
$!str, $nextpos, $!chars - $nextpos)),
$found
),
IterationEnd
)
}
method push-all($target --> IterationEnd) {
my int $left;

0 comments on commit b8f37bf

Please sign in to comment.
You can’t perform that action at this time.