[libcxx-commits] [PATCH] D151260: [Demangle] avoid more std::string_view::substr
Fangrui Song via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Tue May 23 15:29:09 PDT 2023
MaskRay added inline comments.
================
Comment at: libcxxabi/src/demangle/StringViewExtras.h:25
+inline bool starts_with(std::string_view self, char C) noexcept {
return !self.empty() && self.front() == C;
}
----------------
nickdesaulniers wrote:
> nickdesaulniers wrote:
> > `front` is not `noexcept`. Should I rewrite this to be `&*self == C`?
> https://en.cppreference.com/w/cpp/string/basic_string_view/front
Ah, `*self == C` looks good. It's a pity that `front` throws...
================
Comment at: llvm/include/llvm/Demangle/StringViewExtras.h:32
+ return true;
+ if (needle.length() > haystack.length())
+ return false;
----------------
`size` is more common than `length`.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D151260/new/
https://reviews.llvm.org/D151260
More information about the libcxx-commits
mailing list