From: Mark Wielaard Date: Mon, 4 Jun 2018 09:06:44 +0000 (+0200) Subject: readelf: Lookup gettext "yes" and "no" only once. X-Git-Tag: elfutils-0.172~28 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bb5599d8085eb4bb186b711a8c16cea4334c70b4;p=thirdparty%2Felfutils.git readelf: Lookup gettext "yes" and "no" only once. On my machine eu-readelf -N --debug-dump=info libxul.so > /dev/null goes from 63 seconds to 57 seconds. Signed-off-by: Mark Wielaard --- diff --git a/src/ChangeLog b/src/ChangeLog index 19f421077..9ee9650c8 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,10 @@ +2018-06-04 Mark Wielaard + + * readelf.c (yes_str): New static char pointer. + (no_str): Likewise. + (main): Set yes_str and no_str using gettext. + (attr_callback): Use yes_str and no_str instead of calling gettext. + 2018-06-04 Mark Wielaard * readelf.c (main): Call __fsetlocking (stdout, FSETLOCKING_BYCALLER). diff --git a/src/readelf.c b/src/readelf.c index a578b2764..81d10944d 100644 --- a/src/readelf.c +++ b/src/readelf.c @@ -309,6 +309,10 @@ static void print_strings (Ebl *ebl); static void dump_archive_index (Elf *, const char *); +/* Looked up once with gettext in main. */ +static char *yes_str; +static char *no_str; + int main (int argc, char *argv[]) { @@ -321,6 +325,10 @@ main (int argc, char *argv[]) /* Initialize the message catalog. */ textdomain (PACKAGE_TARNAME); + /* Look up once. */ + yes_str = gettext ("yes"); + no_str = gettext ("yes"); + /* Parse and process arguments. */ int remaining; argp_parse (&argp, argc, argv, 0, &remaining, NULL); @@ -7370,7 +7378,7 @@ attr_callback (Dwarf_Attribute *attrp, void *arg) printf (" %*s%-20s (%s) %s\n", (int) (level * 2), "", dwarf_attr_name (attr), - dwarf_form_name (form), flag ? gettext ("yes") : gettext ("no")); + dwarf_form_name (form), flag ? yes_str : no_str); break; case DW_FORM_flag_present: @@ -7378,7 +7386,7 @@ attr_callback (Dwarf_Attribute *attrp, void *arg) break; printf (" %*s%-20s (%s) %s\n", (int) (level * 2), "", dwarf_attr_name (attr), - dwarf_form_name (form), gettext ("yes")); + dwarf_form_name (form), yes_str); break; case DW_FORM_exprloc: