Use std::end instead of repeating buffer sizes.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@259312 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Craig Topper 2016-01-31 01:12:35 +00:00
parent 95769998f9
commit ff0b4a2d25
2 changed files with 7 additions and 7 deletions

View File

@ -71,12 +71,12 @@ static inline char *utohex_buffer(IntTy X, char *BufferEnd, bool LowerCase = fal
static inline std::string utohexstr(uint64_t X, bool LowerCase = false) {
char Buffer[17];
return utohex_buffer(X, Buffer+17, LowerCase);
return utohex_buffer(X, std::end(Buffer), LowerCase);
}
static inline std::string utostr_32(uint32_t X, bool isNeg = false) {
char Buffer[11];
char *BufPtr = Buffer+11;
char *BufPtr = std::end(Buffer);
if (X == 0) *--BufPtr = '0'; // Handle special case...
@ -87,12 +87,12 @@ static inline std::string utostr_32(uint32_t X, bool isNeg = false) {
if (isNeg) *--BufPtr = '-'; // Add negative sign...
return std::string(BufPtr, Buffer+11);
return std::string(BufPtr, std::end(Buffer));
}
static inline std::string utostr(uint64_t X, bool isNeg = false) {
char Buffer[21];
char *BufPtr = Buffer+21;
char *BufPtr = std::end(Buffer);
if (X == 0) *--BufPtr = '0'; // Handle special case...
@ -102,7 +102,7 @@ static inline std::string utostr(uint64_t X, bool isNeg = false) {
}
if (isNeg) *--BufPtr = '-'; // Add negative sign...
return std::string(BufPtr, Buffer+21);
return std::string(BufPtr, std::end(Buffer));
}

View File

@ -141,7 +141,7 @@ raw_ostream &raw_ostream::operator<<(unsigned long long N) {
return this->operator<<(static_cast<unsigned long>(N));
char NumberBuffer[20];
char *EndPtr = NumberBuffer+sizeof(NumberBuffer);
char *EndPtr = std::end(NumberBuffer);
char *CurPtr = EndPtr;
while (N) {
@ -167,7 +167,7 @@ raw_ostream &raw_ostream::write_hex(unsigned long long N) {
return *this << '0';
char NumberBuffer[20];
char *EndPtr = NumberBuffer+sizeof(NumberBuffer);
char *EndPtr = std::end(NumberBuffer);
char *CurPtr = EndPtr;
while (N) {