These are 8 bytes and we don't care about the actual ordering, so use
integer compare.
The array generated code has some extra byte swaps (clang), calls memcmp (gcc)
or inlines a big chain of comparisons (MSVC): https://godbolt.org/z/e79r6jM6K
}
bool operator!=(const SymbolID &Sym) const { return !(*this == Sym); }
bool operator<(const SymbolID &Sym) const {
- return HashValue < Sym.HashValue;
+ // Avoid lexicographic compare which requires swapping bytes or even memcmp!
+ return llvm::bit_cast<IntTy>(HashValue) <
+ llvm::bit_cast<IntTy>(Sym.HashValue);
}
// The stored hash is truncated to RawSize bytes.
explicit operator bool() const { return !isNull(); }
private:
+ using IntTy = uint64_t;
+ static_assert(sizeof(IntTy) == RawSize);
std::array<uint8_t, RawSize> HashValue{};
};