]> git.ipfire.org Git - thirdparty/elfutils.git/commit
readelf.c: Avoid repeating calls to gettext _() in hotpath users/amerey/try-readelf-concurrency
authorAaron Merey <amerey@redhat.com>
Mon, 30 Jun 2025 03:51:55 +0000 (23:51 -0400)
committerAaron Merey <amerey@redhat.com>
Thu, 3 Jul 2025 18:24:57 +0000 (14:24 -0400)
commitce8906bd74bfc8dec72ef1891f998c1c57849789
tree23166e3db5095e5d434716e06ec94648f6862fc3
parent56d9896abcb8a9a648192d570635f519c4a63021
readelf.c: Avoid repeating calls to gettext _() in hotpath

Calls to the gettext _() macro in hotpaths cause many runtime lookups
of the same translation strings.  This patch introduces macro __()
which caches the result of _() at each call site where __() is used.

When a cached translation string is used as the format string for
fprintf, the compiler might raise a -Wformat-nonliteral warning.

To avoid this, the -Wformat-nonliteral warning is suppressed using _Pragma
around affected fprintf calls, using IGNORE_FMT_NONLITERAL_BEGIN and
_END wrappers.

To avoid suppressing -Wformat-nonliteral across every printf-style
function using _(), __() and IGNORE_FMT_NONLITERAL_* are mostly used
within hotpath loops where caching makes a signficant difference.
Runtime improvements of up to 13% faster have been observed with this patch
applied.

Signed-off-by: Aaron Merey <amerey@redhat.com>
src/readelf.c