bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug gas/29794] find_reloc_table_entry in tc-aarch64.c should be speed u


From: pinskia at gcc dot gnu.org
Subject: [Bug gas/29794] find_reloc_table_entry in tc-aarch64.c should be speed up
Date: Wed, 16 Nov 2022 19:04:34 +0000

https://sourceware.org/bugzilla/show_bug.cgi?id=29794

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
There is another thing which could be done is do strchr up front to find the
other : and then match the length and not do the strncasecmp in that case.

That is:
static struct reloc_table_entry *
find_reloc_table_entry (char **str)
{
  unsigned int i;
  const char *relocnameinstrend = strchr(*str, ':');
  if (!relocnameinstrend)
    return NULL;

  int reloclengthinstr = *str - relocnameinstrend;
  for (i = 0; i < ARRAY_SIZE (reloc_table); i++)
    {
      int length = reloc_table[i].name_length;
      if (length == -1)
        length = strlen (reloc_table[i].name);
      if (reloclengthinstr != length)
        continue;

      if (strncasecmp (reloc_table[i].name, *str, length) == 0
          && (*str)[length] == ':')
        {
          *str += (length + 1);
          return &reloc_table[i];
        }
    }

  return NULL;
}

----- CUT ----
These two should give a reasonable speed up I think. Also reording the list to
the most used first will also speed it up (I think that is the reason why lo12
is first already).

-- 
You are receiving this mail because:
You are on the CC list for the bug.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]