[ELF] Use llvm::toLower instead of libc call tolower
authorFangrui Song <maskray@google.com>
Sat, 15 Sep 2018 23:59:13 +0000 (23:59 +0000)
committerFangrui Song <maskray@google.com>
Sat, 15 Sep 2018 23:59:13 +0000 (23:59 +0000)
commit3e0a54e9da9f8db15dcf7dab6cd1f402e0a16f47
tree9a6930a2ccf6c4fa7895d292306f613796d2b302
parent70c5f9dff8ae6d4b385974074145cfcf9e48821d
[ELF] Use llvm::toLower instead of libc call tolower

tolower() has some overhead because current locale is considered (though in lld the default "C" locale is used which does not matter too much). llvm::toLower is more efficient as it compiles to a compare and a conditional jump, as opposed to a libc call if tolower is used.

Disregarding locale also matches gdb's behavior (gdb/minsyms.h):

    #define SYMBOL_HASH_NEXT(hash, c) \
      ((hash) * 67 + TOLOWER ((unsigned char) (c)) - 113)

where TOLOWER (include/safe-ctype.h) is a macro that uses a lookup table under the hood which is similar to llvm::toLower.

Reviewers: ruiu, espindola

Subscribers: emaste, arichardson, llvm-commits

Differential Revision: https://reviews.llvm.org/D52128

llvm-svn: 342342
lld/ELF/SyntheticSections.cpp