Skip to content

Commit ef756d4

Browse files
committed
Merge branch 'cursor-mem-opts' of github.com:perl6/nqp
2 parents 7f7d915 + 3b28064 commit ef756d4

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

src/QRegex/Cursor.nqp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,15 @@ role NQPCursorRole is export {
8585
}
8686
$csi++;
8787
}
88-
}
88+
}
89+
90+
# Once we've produced the captures, and if we know we're finished and
91+
# will never be backtracked into, we can release cstack and regexsub.
92+
unless nqp::defined($!bstack) {
93+
$!cstack := nqp::null();
94+
$!regexsub := nqp::null();
95+
}
96+
8997
$caps;
9098
}
9199

@@ -212,8 +220,10 @@ role NQPCursorRole is export {
212220
}
213221

214222
method !cursor_fail() {
215-
$!match := nqp::null();
216-
$!bstack := nqp::null();
223+
$!match := nqp::null();
224+
$!bstack := nqp::null();
225+
$!cstack := nqp::null();
226+
$!regexsub := nqp::null();
217227
$!pos := -3;
218228
}
219229

src/QRegex/P6Regex/Actions.nqp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -729,6 +729,9 @@ class QRegex::P6Regex::Actions is HLL::Actions {
729729
)
730730
)
731731
)));
732+
if %*RX<r> {
733+
$qast[2].backtrack('r');
734+
}
732735
$block.push($qast);
733736

734737
$block;

0 commit comments

Comments
 (0)