Add an optional LowerCase argument to hexdigit().
authorDaniel Dunbar <daniel@zuster.org>
Sat, 27 Nov 2010 13:19:46 +0000 (13:19 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Sat, 27 Nov 2010 13:19:46 +0000 (13:19 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120213 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/ADT/StringExtras.h

index 3c53adee63c8016fa812c70b29a3d4446bfcba3a..263723294a714de89f05a42eaf5e48dc40933c85 100644 (file)
 namespace llvm {
 template<typename T> class SmallVectorImpl;
 
-/// hexdigit - Return the (uppercase) hexadecimal character for the
+/// hexdigit - Return the hexadecimal character for the
 /// given number \arg X (which should be less than 16).
-static inline char hexdigit(unsigned X) {
-  return X < 10 ? '0' + X : 'A' + X - 10;
+static inline char hexdigit(unsigned X, bool LowerCase = false) {
+  const char HexChar = LowerCase ? 'a' : 'A';
+  return X < 10 ? '0' + X : HexChar + X - 10;
 }
 
 /// utohex_buffer - Emit the specified number into the buffer specified by