diff options
| author | Patrick Palka <ppalka@redhat.com> | 2026-01-30 12:29:17 -0500 |
|---|---|---|
| committer | Patrick Palka <ppalka@redhat.com> | 2026-01-30 12:29:17 -0500 |
| commit | ead66d5f229edda244d1a91125524eca9abdb9b9 (patch) | |
| tree | 25a9d443906d9877d0e54763bea9fc510c001b30 /libjava/classpath/java | |
| parent | 158ad5f96954da5fa24d5c2a91ae92417fb62e20 (diff) | |
| download | gcc-ead66d5f229edda244d1a91125524eca9abdb9b9.zip gcc-ead66d5f229edda244d1a91125524eca9abdb9b9.tar.gz gcc-ead66d5f229edda244d1a91125524eca9abdb9b9.tar.bz2 | |
libstdc++/regex: Defer _M_current restoration to backtracking nodes [PR86164]
The incrementing of the current input string position (_M_current) is
done by _M_handle_match, which also makes sure to restore it afterwards,
via a restore_current frame. But restoring _M_current is naturally only
necessary when backtracking is involved, not after every single match.
So this patch moves the responsibility of saving/restoring _M_current
from _M_handle_match to the branching nodes _M_handle_alternative and
_M_handle_repeat. This is done by storing _M_current within the
fallback_next, fallback_rep_once_more and posix_alternative frames.
In turn we can get rid of the now unused restore_current frame kind.
This reduces the maximum size of the _M_frames stack by 15% for
regex_match(string(200000, 'a'), "(a|b|c)*")
PR libstdc++/86164
libstdc++-v3/ChangeLog:
* include/bits/regex_executor.tcc (__detail::_ExecutorFrameOpcode):
Remove _S_fopcode_restore_current.
(__detail::_Executor::_M_handle_repeat): Pass _M_current when
pushing a fallback_next or fallback_rep_once_more frame.
(__detail::_Executor::_M_handle_match): Don't push a
restore_current frame.
(__detail::_Executor::_M_handle_backref): Likewise and simplify
accordingly.
(__detail::_Executor::_M_handle_alternative): Pass _M_current when
pushing a fallback_next or posix_alternative frame.
(__detail::_Executor::_M_dfs) <case _S_fopcode_fallback_next>:
Restore _M_current.
<case _S_fopcode_fallback_rep_once_more>: Likewise.
<case _S_fopcode_posix_alternative>: Likewise.
<case _S_fopcode_restore_current>: Remove.
Reviewed-by: Tomasz KamiĆski <tkaminsk@redhat.com>
Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Diffstat (limited to 'libjava/classpath/java')
0 files changed, 0 insertions, 0 deletions
