[libc-commits] [PATCH] D97330: [libc] Add a standalone flavor of an equivalent of std::string_view.

Tue Ly via Phabricator via libc-commits libc-commits at lists.llvm.org
Tue Feb 23 14:32:15 PST 2021


lntue added inline comments.


================
Comment at: libc/utils/CPP/StringView.h:42
+  explicit StringView(const char *Str, size_t N)
+      : Data(N ? Str : nullptr), Len(N) {}
+
----------------
Do we need error checking for the case when Str == nullptr but N > 0?


================
Comment at: libc/utils/CPP/StringView.h:70
+    size_t SuffixLen = 0;
+    const char *NewEnd = Data + Len - 1;
+    for (; SuffixLen < Len; --NewEnd, ++SuffixLen) {
----------------
I think we need early exit when Data == nullptr, since it will reach here in that case.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97330



More information about the libc-commits mailing list