[cfe-commits] r165217 - /cfe/trunk/lib/Driver/OptTable.cpp

Benjamin Kramer benny.kra at googlemail.com
Thu Oct 4 03:06:39 PDT 2012


Author: d0k
Date: Thu Oct  4 05:06:38 2012
New Revision: 165217

URL: http://llvm.org/viewvc/llvm-project?rev=165217&view=rev
Log:
Prefer StringRef::startswith to the strncmp/strlen contraption.

This may be slightly more efficient and is definitely more readable.

Modified:
    cfe/trunk/lib/Driver/OptTable.cpp

Modified: cfe/trunk/lib/Driver/OptTable.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/OptTable.cpp?rev=165217&r1=165216&r2=165217&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/OptTable.cpp (original)
+++ cfe/trunk/lib/Driver/OptTable.cpp Thu Oct  4 05:06:38 2012
@@ -159,10 +159,11 @@
   // 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;





More information about the cfe-commits mailing list