[llvm] [DebugNames] Compare TableEntry names more efficiently (PR #79759)

Adrian Prantl via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 29 16:49:44 PST 2024


adrian-prantl wrote:

> So the function could be written, I think, as `return Data.size() >= Target.size() && strncmp(Data.data(), Target.data(), Target.size()) == 0 && !Data[Target.size()];` I think? Something like that

I'd expect that to at least in theory be able to beat the loop in this patch because strncmp could be some clever vectorized/unrolled/whatever implementation, but my guess is that since most comparisons fail early, that advantage practically doesn't matter. I would still mildly prefer the strncmp variant over the loop...

https://github.com/llvm/llvm-project/pull/79759


More information about the llvm-commits mailing list