diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2012-10-04 10:06:38 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2012-10-04 10:06:38 +0000 |
commit | cbdc1a3432c897c11b6d256d556a8a11368729ad (patch) | |
tree | d31cda2878cf06a7562ba24e86d9325403d6bbcd /lib/Driver/OptTable.cpp | |
parent | 429fce9945f2792ca50c864de63ac3c0395e4ad5 (diff) |
Prefer StringRef::startswith to the strncmp/strlen contraption.
This may be slightly more efficient and is definitely more readable.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165217 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Driver/OptTable.cpp')
-rw-r--r-- | lib/Driver/OptTable.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/Driver/OptTable.cpp b/lib/Driver/OptTable.cpp index 257f3537a1..e108106fa7 100644 --- a/lib/Driver/OptTable.cpp +++ b/lib/Driver/OptTable.cpp @@ -159,10 +159,11 @@ Arg *OptTable::ParseOneArg(const ArgList &Args, unsigned &Index) const { // FIXME: This is searching much more than necessary, but I am // blanking on the simplest way to make it fast. We can solve this // problem when we move to TableGen. + StringRef StrRef(Str); for (; Start != End; ++Start) { // Scan for first option which is a proper prefix. for (; Start != End; ++Start) - if (strncmp(Str, Start->Name, strlen(Start->Name)) == 0) + if (StrRef.startswith(Start->Name)) break; if (Start == End) break; |