Skip to content

Commit

Permalink
scripts/kallsyms: replace prefix_underscores_count() with strspn()
Browse files Browse the repository at this point in the history
You can do equivalent things with strspn(). I do not see noticeable
performance difference.

Signed-off-by: Masahiro Yamada <[email protected]>
  • Loading branch information
masahir0y committed Nov 25, 2019
1 parent 29e55ad commit aa91524
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions scripts/kallsyms.c
Original file line number Diff line number Diff line change
Expand Up @@ -661,16 +661,6 @@ static int may_be_linker_script_provide_symbol(const struct sym_entry *se)
return 0;
}

static int prefix_underscores_count(const char *str)
{
const char *tail = str;

while (*tail == '_')
tail++;

return tail - str;
}

static int compare_symbols(const void *a, const void *b)
{
const struct sym_entry *sa;
Expand Down Expand Up @@ -699,8 +689,8 @@ static int compare_symbols(const void *a, const void *b)
return wa - wb;

/* sort by the number of prefix underscores */
wa = prefix_underscores_count(sym_name(sa));
wb = prefix_underscores_count(sym_name(sb));
wa = strspn(sym_name(sa), "_");
wb = strspn(sym_name(sb), "_");
if (wa != wb)
return wa - wb;

Expand Down

0 comments on commit aa91524

Please sign in to comment.