diff options
author | Martin Storsjö <martin@martin.st> | 2021-06-23 14:52:36 +0300 |
---|---|---|
committer | Martin Storsjö <martin@martin.st> | 2021-06-25 00:22:00 +0300 |
commit | 3eed57e7ef7da5eda765ccc19fd26fb8dfcd8d41 (patch) | |
tree | d4fa0590c5a509a52e5c5d564d90eebe8a0c7167 /llvm/lib/Support/StringRef.cpp | |
parent | d09218a82e1a5dc082bff0b0c4f5cfbdf7736c7d (diff) | |
download | llvm-3eed57e7ef7da5eda765ccc19fd26fb8dfcd8d41.zip llvm-3eed57e7ef7da5eda765ccc19fd26fb8dfcd8d41.tar.gz llvm-3eed57e7ef7da5eda765ccc19fd26fb8dfcd8d41.tar.bz2 |
[ADT] Rename StringRef case insensitive methods for clarity
Rename functions with the `xx_lower()` names to `xx_insensitive()`.
This was requested during the review of D104218.
Test names and variables in llvm/unittests/ADT/StringRefTest.cpp
that refer to "lower" are renamed to "insensitive" correspondingly.
Unused function aliases with the former method names are left
in place (without any deprecation attributes) for transition purposes.
All references within the monorepo will be changed (with essentially
mechanical changes), and then the old names will be removed in a
later commit.
Also remove the superfluous method names at the start of doxygen
comments, for the methods that are touched here. (There are more
occurrances of this left in other methods though.) Also remove
duplicate doxygen comments from the implementation file.
Differential Revision: https://reviews.llvm.org/D104819
Diffstat (limited to 'llvm/lib/Support/StringRef.cpp')
-rw-r--r-- | llvm/lib/Support/StringRef.cpp | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/llvm/lib/Support/StringRef.cpp b/llvm/lib/Support/StringRef.cpp index ab67ef9..c532a1a 100644 --- a/llvm/lib/Support/StringRef.cpp +++ b/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; |