Skip to content

Commit

Permalink
Use startswith_lower() where possible.
Browse files Browse the repository at this point in the history
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194007 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
Jakub Staszak committed Nov 4, 2013
1 parent 2e58f1d commit 42f2a6b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 9 deletions.
9 changes: 1 addition & 8 deletions lib/Option/OptTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,13 +175,6 @@ static bool isInput(const llvm::StringSet<> &Prefixes, StringRef Arg) {
return true;
}

// Returns true if X starts with Y, ignoring case.
static bool startsWithIgnoreCase(StringRef X, StringRef Y) {
if (X.size() < Y.size())
return false;
return X.substr(0, Y.size()).equals_lower(Y);
}

/// \returns Matched size. 0 means no match.
static unsigned matchOption(const OptTable::Info *I, StringRef Str,
bool IgnoreCase) {
Expand All @@ -190,7 +183,7 @@ static unsigned matchOption(const OptTable::Info *I, StringRef Str,
if (Str.startswith(Prefix)) {
StringRef Rest = Str.substr(Prefix.size());
bool Matched = IgnoreCase
? startsWithIgnoreCase(Rest, I->Name)
? Rest.startswith_lower(I->Name)
: Rest.startswith(I->Name);
if (Matched)
return Prefix.size() + StringRef(I->Name).size();
Expand Down
2 changes: 1 addition & 1 deletion tools/bugpoint/ToolRunner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,7 @@ static bool IsARMArchitecture(std::vector<const char*> Args) {
I = Args.begin(), E = Args.end(); I != E; ++I) {
if (StringRef(*I).equals_lower("-arch")) {
++I;
if (I != E && StringRef(*I).substr(0, strlen("arm")).equals_lower("arm"))
if (I != E && StringRef(*I).startswith_lower("arm"))
return true;
}
}
Expand Down

0 comments on commit 42f2a6b

Please sign in to comment.