From b61e94fcf898a8b3b6bf7a8a18b390b82ff037f5 Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Sun, 11 Apr 2010 19:00:03 +0000 Subject: [PATCH] utostr isn't going away too soon, try to make it slightly smaller. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@100977 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/ADT/StringExtras.h | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/include/llvm/ADT/StringExtras.h b/include/llvm/ADT/StringExtras.h index 1ea546f46f2..3c53adee63c 100644 --- a/include/llvm/ADT/StringExtras.h +++ b/include/llvm/ADT/StringExtras.h @@ -57,15 +57,14 @@ static inline char *utohex_buffer(IntTy X, char *BufferEnd) { } 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 @@ static inline std::string utostr_32(uint32_t X, bool isNeg = false) { 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 @@ static inline std::string utostr(uint64_t X, bool isNeg = false) { } if (isNeg) *--BufPtr = '-'; // Add negative sign... - return std::string(BufPtr); + return std::string(BufPtr, Buffer+21); }