Skip to content

Commit

Permalink
Be more eager to throw out things we'll not need.
Browse files Browse the repository at this point in the history
This saves memory and eases the GC's role, especially as we keep hold
of a lot less call frames.
  • Loading branch information
jnthn committed Nov 24, 2013
1 parent f4514bb commit 3b28064
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/QRegex/Cursor.nqp
Expand Up @@ -85,7 +85,15 @@ role NQPCursorRole is export {
}
$csi++;
}
}
}

# Once we've produced the captures, and if we know we're finished and
# will never be backtracked into, we can release cstack and regexsub.
unless nqp::defined($!bstack) {
$!cstack := nqp::null();
$!regexsub := nqp::null();
}

$caps;
}

Expand Down Expand Up @@ -212,8 +220,10 @@ role NQPCursorRole is export {
}

method !cursor_fail() {
$!match := nqp::null();
$!bstack := nqp::null();
$!match := nqp::null();
$!bstack := nqp::null();
$!cstack := nqp::null();
$!regexsub := nqp::null();
$!pos := -3;
}

Expand Down
3 changes: 3 additions & 0 deletions src/QRegex/P6Regex/Actions.nqp
Expand Up @@ -729,6 +729,9 @@ class QRegex::P6Regex::Actions is HLL::Actions {
)
)
)));
if %*RX<r> {
$qast[2].backtrack('r');
}
$block.push($qast);

$block;
Expand Down

0 comments on commit 3b28064

Please sign in to comment.