[llvm-commits] [llvm] r120213 - /llvm/trunk/include/llvm/ADT/StringExtras.h

Daniel Dunbar daniel at zuster.org
Sat Nov 27 05:19:46 PST 2010


Author: ddunbar
Date: Sat Nov 27 07:19:46 2010
New Revision: 120213

URL: http://llvm.org/viewvc/llvm-project?rev=120213&view=rev
Log:
Add an optional LowerCase argument to hexdigit().

Modified:
    llvm/trunk/include/llvm/ADT/StringExtras.h

Modified: llvm/trunk/include/llvm/ADT/StringExtras.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/StringExtras.h?rev=120213&r1=120212&r2=120213&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/StringExtras.h (original)
+++ llvm/trunk/include/llvm/ADT/StringExtras.h Sat Nov 27 07:19:46 2010
@@ -25,10 +25,11 @@
 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





More information about the llvm-commits mailing list