[PATCH] D33503: Make BinaryStreamReader::readCString a bit faster.

Reid Kleckner via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 25 14:32:44 PDT 2017


rnk added a comment.

Hm, did my comment not make it through?



================
Comment at: llvm/lib/Support/BinaryStreamReader.cpp:52-54
+    StringRef S(reinterpret_cast<const char *>(Buffer.begin()), Buffer.size());
+    size_t Pos = S.find_first_of('\0');
+    if (LLVM_LIKELY(Pos != StringRef::npos)) {
----------------
How about `S = S.take_front(strnlen(S.data(), S.size()))`? There are some neat tricks for making strlen fast that don't work for memchr.


Repository:
  rL LLVM

https://reviews.llvm.org/D33503





More information about the llvm-commits mailing list