[PATCH] D133658: [Support] Use find() for faster StringRef::count.
Nikita Popov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 26 05:58:43 PDT 2022
nikic added inline comments.
================
Comment at: llvm/lib/Support/StringRef.cpp:374
size_t N = Str.size();
- if (!N || N > Length)
- return 0;
----------------
ishitatsuyuki wrote:
> nikic wrote:
> > The `!N` condition needs to be retained, otherwise we will go into an infinite loop for an empty `Str`. I believe this causes the ADTTest timeout.
> >
> > (Returning `0` for an empty string isn't really right, this should return `Length + 1`, but this is orthogonal to your change.)
> Looks like there's a test with hardcoded expect result of 0. Should I change the test too or retain the old behavior?
I'd suggest keeping the old behavior in this patch (maybe with a TODO) to keep it NFC. We should fix this separately.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D133658/new/
https://reviews.llvm.org/D133658
More information about the llvm-commits
mailing list