[llvm-commits] [llvm] r82415 - /llvm/trunk/lib/Support/StringRef.cpp

Chris Lattner sabre at nondot.org
Sun Sep 20 15:56:43 PDT 2009


Author: lattner
Date: Sun Sep 20 17:56:43 2009
New Revision: 82415

URL: http://llvm.org/viewvc/llvm-project?rev=82415&view=rev
Log:
simplify as daniel suggests

Modified:
    llvm/trunk/lib/Support/StringRef.cpp

Modified: llvm/trunk/lib/Support/StringRef.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/StringRef.cpp?rev=82415&r1=82414&r2=82415&view=diff

==============================================================================
--- llvm/trunk/lib/Support/StringRef.cpp (original)
+++ llvm/trunk/lib/Support/StringRef.cpp Sun Sep 20 17:56:43 2009
@@ -89,23 +89,16 @@
                                  unsigned long long &Result) {
   // Autosense radix if not specified.
   if (Radix == 0) {
-    if (Str[0] != '0') {
+    if (Str.startswith("0x")) {
+      Str = Str.substr(2);
+      Radix = 16;
+    } else if (Str.startswith("0b")) {
+      Str = Str.substr(2);
+      Radix = 2;
+    } else if (Str.startswith("0"))
+      Radix = 8;
+    else
       Radix = 10;
-    } else {
-      if (Str.size() < 2) {
-        Radix = 8;
-      } else {
-        if (Str[1] == 'x') {
-          Str = Str.substr(2);
-          Radix = 16;
-        } else if (Str[1] == 'b') {
-          Str = Str.substr(2);
-          Radix = 2;
-        } else {
-          Radix = 8;
-        }
-      }
-    }
   }
   
   // Empty strings (after the radix autosense) are invalid.





More information about the llvm-commits mailing list