[Lldb-commits] [PATCH] D122974: prevent ConstString from calling djbHash() more than once

Jonas Devlieghere via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Sat Apr 2 09:16:25 PDT 2022

JDevlieghere added a comment.

The ConstString/StringPool is pretty hot so I'm very excited about making it faster.

I'm slightly concerned about the two hash values (the "full" hash vs the single byte one). That's not something that was introduced in this patch, but passing it around adds an opportunity to get it wrong.

I'm wondering if we could wrap this in a struct and pass that around:

  struct HashedStringRef {
    const llvm::StringRef str;
    const unsigned full_hash;
    const uint8_t hash; 
    HashedStringRef(llvm::StringRef s) : str(s), full_hash(djbHash(str)), hash(hash(str)) {}

It looks like we always need both except in the StringMap implementation, but if I'm reading the code correctly we'll have constructed it in ConstString already anyway?

  rG LLVM Github Monorepo



More information about the lldb-commits mailing list