[PATCH] D133658: [Support] Use find() for faster StringRef::count.

Tatsuyuki Ishi via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 26 04:11:17 PDT 2022


ishitatsuyuki added inline comments.


================
Comment at: llvm/lib/Support/StringRef.cpp:374
   size_t N = Str.size();
-  if (!N || N > Length)
-    return 0;
----------------
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?


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