summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLenny Maiorani <lenny@colorado.edu>2011-04-28 20:20:12 +0000
committerLenny Maiorani <lenny@colorado.edu>2011-04-28 20:20:12 +0000
commit367342e20920e533e63b06b3803e7be5609ac52d (patch)
tree1bfb8c6cf7eb6962566236cdfa2130040508626d
parent7cd5101ad3dccbe406b69598ddf04129e801d292 (diff)
downloadbcm5719-llvm-367342e20920e533e63b06b3803e7be5609ac52d.tar.gz
bcm5719-llvm-367342e20920e533e63b06b3803e7be5609ac52d.zip
Remove bounded StringRef::compare() since nothing but Clang SA was using it and it is just as easy to use StringRef::substr() preceding StringRef::compare() to achieve the same thing.
llvm-svn: 130430
-rw-r--r--llvm/include/llvm/ADT/StringRef.h6
-rw-r--r--llvm/lib/Support/StringRef.cpp21
-rw-r--r--llvm/unittests/ADT/StringRefTest.cpp13
3 files changed, 0 insertions, 40 deletions
diff --git a/llvm/include/llvm/ADT/StringRef.h b/llvm/include/llvm/ADT/StringRef.h
index adff42fe2d9..1766d2b9f2d 100644
--- a/llvm/include/llvm/ADT/StringRef.h
+++ b/llvm/include/llvm/ADT/StringRef.h
@@ -125,12 +125,6 @@ namespace llvm {
return Length < RHS.Length ? -1 : 1;
}
- /// compare - Compare two strings; the result is -1, 0, or 1 if this string
- /// is lexicographically less than, equal to, or greater than the \arg RHS.
- /// This is different than compare with no size specified as it only
- /// compares at most the first n bytes.
- int compare(StringRef RHS, size_t n) const;
-
/// compare_lower - Compare two strings, ignoring case.
int compare_lower(StringRef RHS) const;
diff --git a/llvm/lib/Support/StringRef.cpp b/llvm/lib/Support/StringRef.cpp
index 066e7743ae4..8c3fc094cd1 100644
--- a/llvm/lib/Support/StringRef.cpp
+++ b/llvm/lib/Support/StringRef.cpp
@@ -29,27 +29,6 @@ static bool ascii_isdigit(char x) {
return x >= '0' && x <= '9';
}
-/// compare - Compare two strings; the result is -1, 0, or 1 if this string
-/// is lexicographically less than, equal to, or greater than the \arg RHS.
-/// This is different than compare with no size specified as it only
-/// compares at most the first n bytes.
-int StringRef::compare(StringRef RHS, size_t n) const {
- // Check the prefix for a mismatch.
- size_t maxToCmp = min(Length, RHS.Length);
- maxToCmp = min(maxToCmp, n);
- if (int Res = memcmp(Data, RHS.Data, maxToCmp))
- return Res < 0 ? -1 : 1;
-
- // Otherwise the prefixes match, so we only need to check the lengths.
- // Be mindful that if the n is less than or equal to the length of either
- // string, that is the same as the strings matching because in that case
- // we only care about the prefix.
- if (((n <= Length) && (n <= RHS.Length)) ||
- (Length == RHS.Length))
- return 0;
- return Length < RHS.Length ? -1 : 1;
-}
-
/// compare_lower - Compare strings, ignoring case.
int StringRef::compare_lower(StringRef RHS) const {
for (size_t I = 0, E = min(Length, RHS.Length); I != E; ++I) {
diff --git a/llvm/unittests/ADT/StringRefTest.cpp b/llvm/unittests/ADT/StringRefTest.cpp
index 633fcc81fd8..5731e4abaf1 100644
--- a/llvm/unittests/ADT/StringRefTest.cpp
+++ b/llvm/unittests/ADT/StringRefTest.cpp
@@ -55,19 +55,6 @@ TEST(StringRefTest, StringOps) {
EXPECT_EQ( 1, StringRef("aab").compare("aa"));
EXPECT_EQ( 1, StringRef("\xFF").compare("\1"));
- EXPECT_EQ(-1, StringRef("aab").compare("aad", 3));
- EXPECT_EQ( 0, StringRef("aab").compare("aab", 3));
- EXPECT_EQ( 1, StringRef("aab").compare("aaa", 3));
- EXPECT_EQ(-1, StringRef("aab").compare("aabb", 4));
- EXPECT_EQ( 1, StringRef("aab").compare("aa", 3));
- EXPECT_EQ( 1, StringRef("\xFF").compare("\1", 3));
- EXPECT_EQ( 0, StringRef("aab").compare("aad", 2));
- EXPECT_EQ( 0, StringRef("aab").compare("aab", 2));
- EXPECT_EQ( 0, StringRef("aab").compare("aab", 4));
- EXPECT_EQ( 0, StringRef("aab").compare("aaa", 2));
- EXPECT_EQ( 0, StringRef("aab").compare("aabb", 3));
- EXPECT_EQ( 0, StringRef("aab").compare("aa", 2));
-
EXPECT_EQ(-1, StringRef("AaB").compare_lower("aAd"));
EXPECT_EQ( 0, StringRef("AaB").compare_lower("aab"));
EXPECT_EQ( 1, StringRef("AaB").compare_lower("AAA"));
OpenPOWER on IntegriCloud