aboutsummaryrefslogtreecommitdiff
path: root/libjava/classpath/lib/gnu/java
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2026-02-10 20:04:28 +0000
committerJonathan Wakely <redi@gcc.gnu.org>2026-02-11 11:00:03 +0000
commitfba29a5e4e59cc9650d650153c98058e650996c7 (patch)
tree17c86b3b221c1c033c5e536ed49b5ecc405ee7d2 /libjava/classpath/lib/gnu/java
parent49d219a5d7a8ad570992a4065268b58a581b7d9f (diff)
downloadgcc-fba29a5e4e59cc9650d650153c98058e650996c7.zip
gcc-fba29a5e4e59cc9650d650153c98058e650996c7.tar.gz
gcc-fba29a5e4e59cc9650d650153c98058e650996c7.tar.bz2
libstdc++: Optimize std::regex_traits lookup functions
Optimize regex_traits::lookup_collatename and regex_traits::lookup_classname. For lookup_collatename we can hoist the static array into a non-dependent function, then call that for the regex_traits<char> specialization without performing any narrowing operations via the ctype facet. For the regex_traits<wchar_t> specialization we populate a std::string for the narrowed result, and call the non-dependent function. For lookup_classname we can avoid the static array entirely, replacing the iteration over that array with a nested switch that implements a kind of manually-unrolled trie, only match one char at a time until we either match a full string or get a mismatch. This avoids narrowing the entire input and storing it in a temporary string. This improves performance by 2-3x for -O2 and below (the benefit is much smaller for -O3). We can also check the input length for random access iterators, and reject any strings longer than "xdigit" without doing any work at all. For silly cases like [:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx:] this gives a 100x improvement. libstdc++-v3/ChangeLog: * include/bits/regex.tcc (__detail::__lookup_collatename): New function. (regex_traits::lookup_collatename): Use new function. Elide redundant narrowing via ctype facet for regex_traits<char>. (regex_traits::lookup_classname): Replace lookup table with handwritten prefix match. Reviewed-by: Tomasz KamiƄski <tkaminsk@redhat.com>
Diffstat (limited to 'libjava/classpath/lib/gnu/java')
0 files changed, 0 insertions, 0 deletions