aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2025-03-08 12:07:40 +0000
committerJonathan Wakely <redi@gcc.gnu.org>2025-03-12 17:02:53 +0000
commit256060380c30e2d8ced63c2f04a0856d46b77343 (patch)
tree3765939380c2adb33601a9ec48f1e77f399eecde /gcc
parent4d2683b04fd329c97e3da09498345fe3ee00455f (diff)
downloadgcc-256060380c30e2d8ced63c2f04a0856d46b77343.zip
gcc-256060380c30e2d8ced63c2f04a0856d46b77343.tar.gz
gcc-256060380c30e2d8ced63c2f04a0856d46b77343.tar.bz2
libstdc++: Optimize basic_format_parse_context::check_dynamic_spec
This change makes the check_dynamic_spec precondition checks slightly faster to compile, and avoids those checks entirely for the common cases of calling check_dynamic_spec_integral or check_dynamic_spec_string. Instead of checking for unique types by keeping counts in an array and looping over that array, we can just keep a sum of how many valid types are present, and check that it equals the total number of types in the pack. The diagnostic is slightly worse now, because there's only a single "invalid template argument types" string that appears in the output, where previously we had either "non-unique template argument type" or "disallowed template argument type", depending on the failure mode. Given that most users will never use this function directly, and probably won't use invalid types anyway, the inferior diagnostic seems acceptable. libstdc++-v3/ChangeLog: * include/std/format (basic_format_parse_context::__once): New variable template. (basic_format_parse_context::__valid_types_for_check_dynamic_spec): New function template for checking argument types. (basic_format_parse_context::__check_dynamic_spec): New function template to implement the common check_dynamic_spec logic. (basic_format_parse_context::check_dynamic_spec_integral): Call __check_dynamic_spec instead of check_dynamic_spec. (basic_format_parse_context::check_dynamic_spec_string): Likewise. Use _CharT instead of char_type consistently. (basic_format_parse_context::check_dynamic_spec): Use __valid_types_for_check_dynamic_spec for precondition checks and call __check_dynamic_spec for checking the arg id. * testsuite/std/format/parse_ctx_neg.cc: Adjust expected errors. Reviewed-by: Tomasz KamiƄski <tkaminsk@redhat.com>
Diffstat (limited to 'gcc')
0 files changed, 0 insertions, 0 deletions