aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Support/StringRef.cpp
diff options
context:
space:
mode:
authorKazu Hirata <kazu@google.com>2022-10-15 15:06:37 -0700
committerKazu Hirata <kazu@google.com>2022-10-15 15:06:37 -0700
commit1b97645e56bf321b06d1353024339958b64fd242 (patch)
tree8847061a98e56a2e254a3efac5c0d27a82dbfa5d /llvm/lib/Support/StringRef.cpp
parente323a904dce5bf248affef811791f4f8d4d45f02 (diff)
downloadllvm-1b97645e56bf321b06d1353024339958b64fd242.zip
llvm-1b97645e56bf321b06d1353024339958b64fd242.tar.gz
llvm-1b97645e56bf321b06d1353024339958b64fd242.tar.bz2
[ADT] Introduce StringRef::{starts,ends}_width{,_insensitive}
This patch introduces: StringRef::starts_with StringRef::starts_with_insensitive StringRef::ends_with StringRef::ends_with_insensitive to be more compatible with std::string and std::string_view. I'm planning to deprecate the existing functions in favor of the new ones. Differential Revision: https://reviews.llvm.org/D136030
Diffstat (limited to 'llvm/lib/Support/StringRef.cpp')
-rw-r--r--llvm/lib/Support/StringRef.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/llvm/lib/Support/StringRef.cpp b/llvm/lib/Support/StringRef.cpp
index 7e19a79..dd54d53 100644
--- a/llvm/lib/Support/StringRef.cpp
+++ b/llvm/lib/Support/StringRef.cpp
@@ -42,12 +42,12 @@ int StringRef::compare_insensitive(StringRef RHS) const {
return Length < RHS.Length ? -1 : 1;
}
-bool StringRef::startswith_insensitive(StringRef Prefix) const {
+bool StringRef::starts_with_insensitive(StringRef Prefix) const {
return Length >= Prefix.Length &&
ascii_strncasecmp(Data, Prefix.Data, Prefix.Length) == 0;
}
-bool StringRef::endswith_insensitive(StringRef Suffix) const {
+bool StringRef::ends_with_insensitive(StringRef Suffix) const {
return Length >= Suffix.Length &&
ascii_strncasecmp(end() - Suffix.Length, Suffix.Data, Suffix.Length) == 0;
}