]> git.ipfire.org Git - thirdparty/gcc.git/commit
libstdc++: Use constexpr-if to slightly simplify <regex>
authorJonathan Wakely <jwakely@redhat.com>
Wed, 18 Dec 2024 18:31:16 +0000 (18:31 +0000)
committerJonathan Wakely <redi@gcc.gnu.org>
Tue, 29 Apr 2025 18:54:35 +0000 (19:54 +0100)
commit52e2bcbd936ed7cc567fe086480076547d2df6b5
tree6af43a4c5ebe2ef67961a121e98baf6f9b7083db
parentd84fbc516ea57de7e88fce76ff6f342ee808c02e
libstdc++: Use constexpr-if to slightly simplify <regex>

This will hardly make a dent in the very slow compile times for <regex>
but it seems worth doing anyway.

libstdc++-v3/ChangeLog:

* include/bits/regex_compiler.h: Replace _GLIBCXX17_CONSTEXPR
with constexpr and disable diagnostics with pragmas.
(_AnyMatcher::operator()): Use constexpr-if instead of tag
dispatching. Postpone calls to _M_translate until after checking
result of earlier calls.
(_AnyMatcher::_M_apply): Remove both overloads.
(_BracketMatcher::operator(), _BracketMatcher::_M_ready):
Replace tag dispatching with 'if constexpr'.
(_BracketMatcher::_M_apply(_CharT, true_type)): Remove.
(_BracketMatcher::_M_apply(_CharT, false_type)): Remove second
parameter.
(_BracketMatcher::_M_make_cache): Remove both overloads.
* include/bits/regex_compiler.tcc (_BracketMatcher::_M_apply):
Remove second parameter.
* include/bits/regex_executor.tcc: Replace _GLIBCXX17_CONSTEXPR
with constexpr and disable diagnostics with pragmas.
(_Executor::_M_handle_backref): Replace __glibcxx_assert with
static_assert.
(_Executor::_M_handle_accept): Mark _S_opcode_backref case as
unreachable for non-DFS mode and do not instantiate
_M_handle_backref for that case.

Reviewed-by: Tomasz KamiƄski <tkaminsk@redhat.com>
libstdc++-v3/include/bits/regex_compiler.h
libstdc++-v3/include/bits/regex_compiler.tcc
libstdc++-v3/include/bits/regex_executor.tcc