Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Used shared fail Curosr in some HLL::Grammar rules
Shaves another 15,000 Cursor creations off when compiling NQP.nqp.
Together with the previous change, that's 25% of Cursor allocations
vanished for this case.
  • Loading branch information
jnthn committed Sep 29, 2013
1 parent 91744f2 commit 0b5feb6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/HLL/Grammar.nqp
Expand Up @@ -368,14 +368,14 @@ position C<pos>.
method starter() {
my $start := $*QUOTE_START;
nqp::isnull($start)
?? self.'!cursor_start_cur'()
?? self.'!cusor_start_fail'()
!! self.'!LITERAL'($start)
}

method stopper() {
my $stop := $*QUOTE_STOP;
nqp::isnull($stop)
?? self.'!cursor_start_cur'()
?? self.'!cursor_start_fail'()
!! self.'!LITERAL'($stop)
}

Expand Down Expand Up @@ -613,7 +613,7 @@ An operator precedence parser.
ParseShared, '%!marks');
my $cur := nqp::atkey(%markhash, $markname);
unless nqp::istype($cur, NQPCursor) && $cur.pos() == self.pos() {
$cur := self."!cursor_start_cur"();
$cur := self.'!cursor_start_fail'();
}
$cur
}
Expand Down
4 changes: 4 additions & 0 deletions src/QRegex/Cursor.nqp
Expand Up @@ -169,6 +169,10 @@ role NQPCursorRole is export {
nqp::bindattr($new, $?CLASS, '$!bstack', nqp::list_i());
$new
}

method !cursor_start_fail() {
nqp::getattr($!shared, ParseShared, '$!fail_cursor');
}

method !cursor_start_subcapture($from) {
my $new := nqp::create(self);
Expand Down

0 comments on commit 0b5feb6

Please sign in to comment.