Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reuse bstack and cstack when restarting a cursor
While cursors and their match extents are immutable and we must make a new one when backtracking, it seems there's no situation where we will backtrack twice into the exact same cursor. Assuming this is correct (I can't think of a case, the tests don't bring up a case), then it is safe to pass ownership of them from one cursor to another. In a case like /a (.+) c/ on a string like "abc" ~ "d" x 8000, this means we do not need to repeatedly clone a huge bstack one per char that we move back. Helps with rakudo/rakudo#4236, where the golf mentioned above uses vastly less memory and runs over 6 times faster.
- Loading branch information