llvm.org GIT mirror llvm / b61e94f
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 Benjamin Kramer 10 years ago
1 changed file(s) with 8 addition(s) and 13 deletion(s). Raw diff Collapse all Expand all
5656 }
5757
5858 static inline std::string utohexstr(uint64_t X) {
59 char Buffer[40];
60 return utohex_buffer(X, Buffer+40);
59 char Buffer[17];
60 return utohex_buffer(X, Buffer+17);
6161 }
6262
6363 static inline std::string utostr_32(uint32_t X, bool isNeg = false) {
64 char Buffer[20];
65 char *BufPtr = Buffer+19;
64 char Buffer[11];
65 char *BufPtr = Buffer+11;
6666
67 *BufPtr = 0; // Null terminate buffer...
6867 if (X == 0) *--BufPtr = '0'; // Handle special case...
6968
7069 while (X) {
7473
7574 if (isNeg) *--BufPtr = '-'; // Add negative sign...
7675
77 return std::string(BufPtr);
76 return std::string(BufPtr, Buffer+11);
7877 }
7978
8079 static inline std::string utostr(uint64_t X, bool isNeg = false) {
81 if (X == uint32_t(X))
82 return utostr_32(uint32_t(X), isNeg);
80 char Buffer[21];
81 char *BufPtr = Buffer+21;
8382
84 char Buffer[40];
85 char *BufPtr = Buffer+39;
86
87 *BufPtr = 0; // Null terminate buffer...
8883 if (X == 0) *--BufPtr = '0'; // Handle special case...
8984
9085 while (X) {
9388 }
9489
9590 if (isNeg) *--BufPtr = '-'; // Add negative sign...
96 return std::string(BufPtr);
91 return std::string(BufPtr, Buffer+21);
9792 }
9893
9994