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

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 30 12:54:39 PST 2024


dwblaikie 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
> 
> @dwblaikie I had to tweak this slightly: we want `Data.size() > Target.size()` instead of `>=`, because a (non-corrupt) string table name must be null terminated and `Data.size()` includes the `\0`.

Oh, yeah, that totally makes sense! :thumbsup:

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


More information about the llvm-commits mailing list