Bitcode reader: replace DecodeChar6() with a lookup table (NFC)
authorMehdi Amini <mehdi.amini@apple.com>
Wed, 10 Feb 2016 22:47:48 +0000 (22:47 +0000)
committerMehdi Amini <mehdi.amini@apple.com>
Wed, 10 Feb 2016 22:47:48 +0000 (22:47 +0000)
Summary: Measured to be more performant when reading bitcode.

Reviewers: rafael, dexonsmith

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D16285

From: Mehdi Amini <mehdi.amini@apple.com>
llvm-svn: 260455

llvm/include/llvm/Bitcode/BitCodes.h

index 96c4201..66400b6 100644 (file)
@@ -147,12 +147,8 @@ public:
 
   static char DecodeChar6(unsigned V) {
     assert((V & ~63) == 0 && "Not a Char6 encoded character!");
-    if (V < 26)       return V+'a';
-    if (V < 26+26)    return V-26+'A';
-    if (V < 26+26+10) return V-26-26+'0';
-    if (V == 62)      return '.';
-    if (V == 63)      return '_';
-    llvm_unreachable("Not a value Char6 character!");
+    return "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789._"
+        [V];
   }
 
 };