From 0b5feb64b6f3d3695b53438b347b635d200f6c65 Mon Sep 17 00:00:00 2001 From: jnthn Date: Sun, 29 Sep 2013 23:14:17 +0200 Subject: [PATCH] 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. --- src/HLL/Grammar.nqp | 6 +++--- src/QRegex/Cursor.nqp | 4 ++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/HLL/Grammar.nqp b/src/HLL/Grammar.nqp index a5fb5f64a7..0cd4c1248e 100644 --- a/src/HLL/Grammar.nqp +++ b/src/HLL/Grammar.nqp @@ -368,14 +368,14 @@ position C. 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) } @@ -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 } diff --git a/src/QRegex/Cursor.nqp b/src/QRegex/Cursor.nqp index c30eae00b6..c9bd702f93 100755 --- a/src/QRegex/Cursor.nqp +++ b/src/QRegex/Cursor.nqp @@ -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);