[all-commits] [llvm/llvm-project] b24a30: [lld-macho] Always store symbol name length eagerl...

Daniel Bertalan via All-commits all-commits at lists.llvm.org
Tue Sep 3 16:05:36 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: b24a304435632710bb54a0cd9cda1757abb8c160
      https://github.com/llvm/llvm-project/commit/b24a304435632710bb54a0cd9cda1757abb8c160
  Author: Daniel Bertalan <dani at danielbertalan.dev>
  Date:   2024-09-04 (Wed, 04 Sep 2024)

  Changed paths:
    M lld/MachO/Symbols.cpp
    M lld/MachO/Symbols.h

  Log Message:
  -----------
  [lld-macho] Always store symbol name length eagerly (NFC) (#106906)

The only instance where we weren't already passing a `StringRef` with a
known length to `Symbol`'s constructor is where the argument is a string
literal. Even in that case, lazy `strlen` calls don't make sense, as the
compiler can constant-evaluate the `StringRef(const char*)` constructor.

For symbols that go into the symbol table we need the length when
calculating the hash anyway. We could get away with not calling
`getName()` for local symbols, but the total contribution of `strlen` to
the run time is already below 1%, so that would just complicate the code
for a negligible benefit.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list