about summary refs log tree commit diff
path: root/absl/strings/numbers.cc
diff options
context:
space:
mode:
authorAbseil Team <absl-team@google.com>2017-12-14T20·36-0800
committerTitus Winters <titus@google.com>2017-12-15T13·52-0500
commit6280bddf55e675219cacc25a6a12bc5ddc0fdc74 (patch)
tree15b87def4e6978fa40eee2cb8db76302bedc7282 /absl/strings/numbers.cc
parent720c017e30339fd1786ce4aac68bc8559736e53f (diff)
Changes imported from Abseil "staging" branch:
  - 8320b38cd9f4f271fb6b278bd1e10d93f6ac3856 Use overloads for int32/int64/uint32/uint64 rather than i... by Jorg Brown <jorg@google.com>
  - f8b582b8deb3f78a3c6de2114b3ec4640f5427dd Internal change by Juemin Yang <jueminyang@google.com>
  - 240ff55ebf493ab1233ebe6976853a5fa2b3ec46 Remove the internal LowLevelAlloc's dependence on kLinker... by Greg Falcon <gfalcon@google.com>

GitOrigin-RevId: 8320b38cd9f4f271fb6b278bd1e10d93f6ac3856
Change-Id: If5004efa2b43856948390ab357b8e9403e4461b4
Diffstat (limited to 'absl/strings/numbers.cc')
-rw-r--r--absl/strings/numbers.cc28
1 files changed, 12 insertions, 16 deletions
diff --git a/absl/strings/numbers.cc b/absl/strings/numbers.cc
index ac73f5308225..31f07c72c949 100644
--- a/absl/strings/numbers.cc
+++ b/absl/strings/numbers.cc
@@ -135,16 +135,12 @@ bool SimpleAtob(absl::string_view str, bool* value) {
 }
 
 // ----------------------------------------------------------------------
-// FastInt32ToBuffer()
-// FastUInt32ToBuffer()
-// FastInt64ToBuffer()
-// FastUInt64ToBuffer()
+// FastIntToBuffer() overloads
 //
 // Like the Fast*ToBuffer() functions above, these are intended for speed.
 // Unlike the Fast*ToBuffer() functions, however, these functions write
-// their output to the beginning of the buffer (hence the name, as the
-// output is left-aligned).  The caller is responsible for ensuring that
-// the buffer has enough space to hold the output.
+// their output to the beginning of the buffer.  The caller is responsible
+// for ensuring that the buffer has enough space to hold the output.
 //
 // Returns a pointer to the end of the std::string (i.e. the null character
 // terminating the std::string).
@@ -160,7 +156,7 @@ const char one_ASCII_final_digits[10][2] {
 
 }  // namespace
 
-char* numbers_internal::FastUInt32ToBuffer(uint32_t i, char* buffer) {
+char* numbers_internal::FastIntToBuffer(uint32_t i, char* buffer) {
   uint32_t digits;
   // The idea of this implementation is to trim the number of divides to as few
   // as possible, and also reducing memory stores and branches, by going in
@@ -230,7 +226,7 @@ char* numbers_internal::FastUInt32ToBuffer(uint32_t i, char* buffer) {
   goto lt100_000_000;
 }
 
-char* numbers_internal::FastInt32ToBuffer(int32_t i, char* buffer) {
+char* numbers_internal::FastIntToBuffer(int32_t i, char* buffer) {
   uint32_t u = i;
   if (i < 0) {
     *buffer++ = '-';
@@ -239,12 +235,12 @@ char* numbers_internal::FastInt32ToBuffer(int32_t i, char* buffer) {
     // we write the equivalent expression "0 - u" instead.
     u = 0 - u;
   }
-  return numbers_internal::FastUInt32ToBuffer(u, buffer);
+  return numbers_internal::FastIntToBuffer(u, buffer);
 }
 
-char* numbers_internal::FastUInt64ToBuffer(uint64_t i, char* buffer) {
+char* numbers_internal::FastIntToBuffer(uint64_t i, char* buffer) {
   uint32_t u32 = static_cast<uint32_t>(i);
-  if (u32 == i) return numbers_internal::FastUInt32ToBuffer(u32, buffer);
+  if (u32 == i) return numbers_internal::FastIntToBuffer(u32, buffer);
 
   // Here we know i has at least 10 decimal digits.
   uint64_t top_1to11 = i / 1000000000;
@@ -252,12 +248,12 @@ char* numbers_internal::FastUInt64ToBuffer(uint64_t i, char* buffer) {
   uint32_t top_1to11_32 = static_cast<uint32_t>(top_1to11);
 
   if (top_1to11_32 == top_1to11) {
-    buffer = numbers_internal::FastUInt32ToBuffer(top_1to11_32, buffer);
+    buffer = numbers_internal::FastIntToBuffer(top_1to11_32, buffer);
   } else {
     // top_1to11 has more than 32 bits too; print it in two steps.
     uint32_t top_8to9 = static_cast<uint32_t>(top_1to11 / 100);
     uint32_t mid_2 = static_cast<uint32_t>(top_1to11 - top_8to9 * 100);
-    buffer = numbers_internal::FastUInt32ToBuffer(top_8to9, buffer);
+    buffer = numbers_internal::FastIntToBuffer(top_8to9, buffer);
     PutTwoDigits(mid_2, buffer);
     buffer += 2;
   }
@@ -283,13 +279,13 @@ char* numbers_internal::FastUInt64ToBuffer(uint64_t i, char* buffer) {
   return buffer + 1;
 }
 
-char* numbers_internal::FastInt64ToBuffer(int64_t i, char* buffer) {
+char* numbers_internal::FastIntToBuffer(int64_t i, char* buffer) {
   uint64_t u = i;
   if (i < 0) {
     *buffer++ = '-';
     u = 0 - u;
   }
-  return numbers_internal::FastUInt64ToBuffer(u, buffer);
+  return numbers_internal::FastIntToBuffer(u, buffer);
 }
 
 // Returns the number of leading 0 bits in a 64-bit value.