[llvm] r259312 - Use std::end instead of repeating buffer sizes.
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Sat Jan 30 17:12:36 PST 2016
Author: ctopper
Date: Sat Jan 30 19:12:35 2016
New Revision: 259312
URL: http://llvm.org/viewvc/llvm-project?rev=259312&view=rev
Log:
Use std::end instead of repeating buffer sizes.
Modified:
llvm/trunk/include/llvm/ADT/StringExtras.h
llvm/trunk/lib/Support/raw_ostream.cpp
Modified: llvm/trunk/include/llvm/ADT/StringExtras.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/StringExtras.h?rev=259312&r1=259311&r2=259312&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/StringExtras.h (original)
+++ llvm/trunk/include/llvm/ADT/StringExtras.h Sat Jan 30 19:12:35 2016
@@ -71,12 +71,12 @@ static inline char *utohex_buffer(IntTy
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(uint
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_
}
if (isNeg) *--BufPtr = '-'; // Add negative sign...
- return std::string(BufPtr, Buffer+21);
+ return std::string(BufPtr, std::end(Buffer));
}
Modified: llvm/trunk/lib/Support/raw_ostream.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/raw_ostream.cpp?rev=259312&r1=259311&r2=259312&view=diff
==============================================================================
--- llvm/trunk/lib/Support/raw_ostream.cpp (original)
+++ llvm/trunk/lib/Support/raw_ostream.cpp Sat Jan 30 19:12:35 2016
@@ -141,7 +141,7 @@ raw_ostream &raw_ostream::operator<<(uns
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(unsi
return *this << '0';
char NumberBuffer[20];
- char *EndPtr = NumberBuffer+sizeof(NumberBuffer);
+ char *EndPtr = std::end(NumberBuffer);
char *CurPtr = EndPtr;
while (N) {
More information about the llvm-commits
mailing list