aboutsummaryrefslogtreecommitdiff
path: root/contrib/llvm-project/llvm/lib/Support/StringRef.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2021-08-22 19:00:43 +0000
committerDimitry Andric <dim@FreeBSD.org>2021-12-06 16:30:02 +0000
commit5f7ddb1456d5b926e85710da690bf548ef0c9fc8 (patch)
treef8845b108c5c07836b95c8229c96cd745fc9fb2c /contrib/llvm-project/llvm/lib/Support/StringRef.cpp
parent3f82687cdf02983d8f3294df4d97b09cf211141b (diff)
Diffstat (limited to 'contrib/llvm-project/llvm/lib/Support/StringRef.cpp')
-rw-r--r--contrib/llvm-project/llvm/lib/Support/StringRef.cpp21
1 files changed, 9 insertions, 12 deletions
diff --git a/contrib/llvm-project/llvm/lib/Support/StringRef.cpp b/contrib/llvm-project/llvm/lib/Support/StringRef.cpp
index ab67ef9ce85c..c532a1abe906 100644
--- a/contrib/llvm-project/llvm/lib/Support/StringRef.cpp
+++ b/contrib/llvm-project/llvm/lib/Support/StringRef.cpp
@@ -34,8 +34,7 @@ static int ascii_strncasecmp(const char *LHS, const char *RHS, size_t Length) {
return 0;
}
-/// compare_lower - Compare strings, ignoring case.
-int StringRef::compare_lower(StringRef RHS) const {
+int StringRef::compare_insensitive(StringRef RHS) const {
if (int Res = ascii_strncasecmp(Data, RHS.Data, std::min(Length, RHS.Length)))
return Res;
if (Length == RHS.Length)
@@ -43,19 +42,17 @@ int StringRef::compare_lower(StringRef RHS) const {
return Length < RHS.Length ? -1 : 1;
}
-/// Check if this string starts with the given \p Prefix, ignoring case.
-bool StringRef::startswith_lower(StringRef Prefix) const {
+bool StringRef::startswith_insensitive(StringRef Prefix) const {
return Length >= Prefix.Length &&
ascii_strncasecmp(Data, Prefix.Data, Prefix.Length) == 0;
}
-/// Check if this string ends with the given \p Suffix, ignoring case.
-bool StringRef::endswith_lower(StringRef Suffix) const {
+bool StringRef::endswith_insensitive(StringRef Suffix) const {
return Length >= Suffix.Length &&
ascii_strncasecmp(end() - Suffix.Length, Suffix.Data, Suffix.Length) == 0;
}
-size_t StringRef::find_lower(char C, size_t From) const {
+size_t StringRef::find_insensitive(char C, size_t From) const {
char L = toLower(C);
return find_if([L](char D) { return toLower(D) == L; }, From);
}
@@ -173,10 +170,10 @@ size_t StringRef::find(StringRef Str, size_t From) const {
return npos;
}
-size_t StringRef::find_lower(StringRef Str, size_t From) const {
+size_t StringRef::find_insensitive(StringRef Str, size_t From) const {
StringRef This = substr(From);
while (This.size() >= Str.size()) {
- if (This.startswith_lower(Str))
+ if (This.startswith_insensitive(Str))
return From;
This = This.drop_front();
++From;
@@ -184,7 +181,7 @@ size_t StringRef::find_lower(StringRef Str, size_t From) const {
return npos;
}
-size_t StringRef::rfind_lower(char C, size_t From) const {
+size_t StringRef::rfind_insensitive(char C, size_t From) const {
From = std::min(From, Length);
size_t i = From;
while (i != 0) {
@@ -211,13 +208,13 @@ size_t StringRef::rfind(StringRef Str) const {
return npos;
}
-size_t StringRef::rfind_lower(StringRef Str) const {
+size_t StringRef::rfind_insensitive(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_lower(Str))
+ if (substr(i, N).equals_insensitive(Str))
return i;
}
return npos;