[llvm] r260455 - Bitcode reader: replace DecodeChar6() with a lookup table (NFC)

Mehdi Amini via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 10 14:47:48 PST 2016


Author: mehdi_amini
Date: Wed Feb 10 16:47:48 2016
New Revision: 260455

URL: http://llvm.org/viewvc/llvm-project?rev=260455&view=rev
Log:
Bitcode reader: replace DecodeChar6() with a lookup table (NFC)

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 at apple.com>

Modified:
    llvm/trunk/include/llvm/Bitcode/BitCodes.h

Modified: llvm/trunk/include/llvm/Bitcode/BitCodes.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Bitcode/BitCodes.h?rev=260455&r1=260454&r2=260455&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Bitcode/BitCodes.h (original)
+++ llvm/trunk/include/llvm/Bitcode/BitCodes.h Wed Feb 10 16:47:48 2016
@@ -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];
   }
 
 };




More information about the llvm-commits mailing list