[PATCH] D27068: Improve string::find

JianYongChan via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon May 9 19:51:30 PDT 2022


Tangmou added inline comments.


================
Comment at: libcxx/trunk/include/__string:557
+  _CharT __f2 = *__first2;
+  while (true) {
+    __len1 = __last1 - __first1;
----------------
Tangmou wrote:
> Sorry for the comment after such a long time, but I have a question about this patch.
> 
> Since we have already calculated `__len1` and ensured that `__len1 < __len2` before the loop,  can we just skip the length calculation and the comparison in the first loop cycle?  And thus we can replace the `while` loop with `do-while` or keep the `while` loop but delete the length calculation and the comparison before the loop?
Sorry, I made a mistake. Please ignore it!


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D27068/new/

https://reviews.llvm.org/D27068



More information about the cfe-commits mailing list