diff options
author | Chris Lattner <sabre@nondot.org> | 2009-09-20 22:56:43 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-09-20 22:56:43 +0000 |
commit | 5a3a8542055538d45d49b8a22b92858d0f120d96 (patch) | |
tree | 31d87e45f603dbac02799c20773c91494efc1405 /llvm/lib/Support | |
parent | 50f387c5f0a5a1e3f999af3f81f342cbdbb552c1 (diff) | |
download | bcm5719-llvm-5a3a8542055538d45d49b8a22b92858d0f120d96.tar.gz bcm5719-llvm-5a3a8542055538d45d49b8a22b92858d0f120d96.zip |
simplify as daniel suggests
llvm-svn: 82415
Diffstat (limited to 'llvm/lib/Support')
-rw-r--r-- | llvm/lib/Support/StringRef.cpp | 25 |
1 files changed, 9 insertions, 16 deletions
diff --git a/llvm/lib/Support/StringRef.cpp b/llvm/lib/Support/StringRef.cpp index af64642a989..a4c0e87c28e 100644 --- a/llvm/lib/Support/StringRef.cpp +++ b/llvm/lib/Support/StringRef.cpp @@ -89,23 +89,16 @@ static bool GetAsUnsignedInteger(StringRef Str, unsigned Radix, 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. |