]> git.ipfire.org Git - thirdparty/glibc.git/commit
stdio-common: avoid repeated regexp matches in tst-printf-format.awk master
authorMatt Turner <mattst88@gmail.com>
Tue, 4 Aug 2026 01:59:44 +0000 (21:59 -0400)
committerSam James <sam@gentoo.org>
Thu, 6 Aug 2026 22:13:36 +0000 (23:13 +0100)
commit0cc3f9b3f3f2950844bd41cc8923215cd5d97269
tree6cd4c44b80b821739d83e0c6be4188b171a6a099
parent866a70167b85903a02d4ccacb91afb8922702c14
stdio-common: avoid repeated regexp matches in tst-printf-format.awk

Whether the value is an infinity, a NaN or zero does not change between
the conversions applied to it, but was determined again for each one.
Determine it where the value is read.

Also look for the '#' flag with index() before matching the expressions
that need it, and test the value first where both have to hold.

For the %f conversion for double, in the C locale, as the median of five
runs:

  x86_64, gawk 5.4.1    1.248s -> 1.184s
  x86_64, gawk 5.3.2    0.703s -> 0.708s
  alpha,  gawk 5.4.60    26.6s ->  25.8s

So this only helps with the regular expression engine that gawk 5.4
brought in; under 5.3.2 it is lost in the noise.  Output and exit status
are unchanged for the e, f and g conversions for double under both
gawk versions and both locales.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
stdio-common/tst-printf-format.awk