aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Support/StringRef.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Support/StringRef.cpp')
-rw-r--r--llvm/lib/Support/StringRef.cpp15
1 files changed, 2 insertions, 13 deletions
diff --git a/llvm/lib/Support/StringRef.cpp b/llvm/lib/Support/StringRef.cpp
index f9fa511..fb93940 100644
--- a/llvm/lib/Support/StringRef.cpp
+++ b/llvm/lib/Support/StringRef.cpp
@@ -215,15 +215,7 @@ size_t StringRef::rfind_insensitive(char C, size_t From) const {
/// \return - The index of the last occurrence of \arg Str, or npos if not
/// found.
size_t StringRef::rfind(StringRef Str) const {
- size_t N = Str.size();
- if (N > Length)
- return npos;
- for (size_t i = Length - N + 1, e = 0; i != e;) {
- --i;
- if (substr(i, N).equals(Str))
- return i;
- }
- return npos;
+ return std::string_view(*this).rfind(Str);
}
size_t StringRef::rfind_insensitive(StringRef Str) const {
@@ -257,10 +249,7 @@ StringRef::size_type StringRef::find_first_of(StringRef Chars,
/// find_first_not_of - Find the first character in the string that is not
/// \arg C or npos if not found.
StringRef::size_type StringRef::find_first_not_of(char C, size_t From) const {
- for (size_type i = std::min(From, Length), e = Length; i != e; ++i)
- if (Data[i] != C)
- return i;
- return npos;
+ return std::string_view(*this).find_first_not_of(C, From);
}
/// find_first_not_of - Find the first character in the string that is not