[llvm-commits] [llvm] r100977 - /llvm/trunk/include/llvm/ADT/StringExtras.h
Benjamin Kramer
benny.kra at googlemail.com
Sun Apr 11 12:00:04 PDT 2010
Author: d0k
Date: Sun Apr 11 14:00:03 2010
New Revision: 100977
URL: http://llvm.org/viewvc/llvm-project?rev=100977&view=rev
Log:
utostr isn't going away too soon, try to make it slightly smaller.
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=100977&r1=100976&r2=100977&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/StringExtras.h (original)
+++ llvm/trunk/include/llvm/ADT/StringExtras.h Sun Apr 11 14:00:03 2010
@@ -57,15 +57,14 @@
}
static inline std::string utohexstr(uint64_t X) {
- char Buffer[40];
- return utohex_buffer(X, Buffer+40);
+ char Buffer[17];
+ return utohex_buffer(X, Buffer+17);
}
static inline std::string utostr_32(uint32_t X, bool isNeg = false) {
- char Buffer[20];
- char *BufPtr = Buffer+19;
+ char Buffer[11];
+ char *BufPtr = Buffer+11;
- *BufPtr = 0; // Null terminate buffer...
if (X == 0) *--BufPtr = '0'; // Handle special case...
while (X) {
@@ -75,17 +74,13 @@
if (isNeg) *--BufPtr = '-'; // Add negative sign...
- return std::string(BufPtr);
+ return std::string(BufPtr, Buffer+11);
}
static inline std::string utostr(uint64_t X, bool isNeg = false) {
- if (X == uint32_t(X))
- return utostr_32(uint32_t(X), isNeg);
+ char Buffer[21];
+ char *BufPtr = Buffer+21;
- char Buffer[40];
- char *BufPtr = Buffer+39;
-
- *BufPtr = 0; // Null terminate buffer...
if (X == 0) *--BufPtr = '0'; // Handle special case...
while (X) {
@@ -94,7 +89,7 @@
}
if (isNeg) *--BufPtr = '-'; // Add negative sign...
- return std::string(BufPtr);
+ return std::string(BufPtr, Buffer+21);
}
More information about the llvm-commits
mailing list