Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
add a temp routine for speed testing of .match
  • Loading branch information
TimToady committed Oct 8, 2015
1 parent 25d3482 commit 472ea02
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/core/Str.pm
Expand Up @@ -366,6 +366,21 @@ my class Str does Stringy { # declared in BOOTSTRAP
!! self.match(:g, :$x, $pat).map: { .Str }
}

# A temporary routine for differential testing of .match overhead.
# This can only be used for a single non-multi match, and does not
# set $/.
method simplematch($pat) {
my $caller_dollar_slash := nqp::getlexcaller('$/');
my %opts;
%opts<c> = 0;
my $patrx := nqp::istype($pat,Code) ?? $pat !! / "$pat": /;
my $cur := $patrx(Cursor.'!cursor_init'(self, |%opts));

$cur.pos >= 0
?? $cur.MATCH_SAVE
!! Nil;
}

method match($pat,
:continue(:$c), :pos(:$p),
:global(:$g), :overlap(:$ov), :exhaustive(:$ex),
Expand Down

0 comments on commit 472ea02

Please sign in to comment.