diff options
Diffstat (limited to 'absl/strings/cord_buffer.h')
-rw-r--r-- | absl/strings/cord_buffer.h | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/absl/strings/cord_buffer.h b/absl/strings/cord_buffer.h index 56a6ce6f..bc0e4e45 100644 --- a/absl/strings/cord_buffer.h +++ b/absl/strings/cord_buffer.h @@ -160,7 +160,6 @@ class CordBuffer { // for more information on buffer capacities and intended usage. static CordBuffer CreateWithDefaultLimit(size_t capacity); - // CordBuffer::CreateWithCustomLimit() // // Creates a CordBuffer instance of the desired `capacity` rounded to an @@ -330,14 +329,13 @@ class CordBuffer { // Returns the available area of the internal SSO data absl::Span<char> short_available() { - assert(is_short()); - const size_t length = (short_rep.raw_size >> 1); + const size_t length = short_length(); return absl::Span<char>(short_rep.data + length, kInlineCapacity - length); } // Returns the available area of the internal SSO data - absl::Span<char> long_available() { + absl::Span<char> long_available() const { assert(!is_short()); const size_t length = long_rep.rep->length; return absl::Span<char>(long_rep.rep->Data() + length, @@ -347,7 +345,7 @@ class CordBuffer { // Returns the length of the internal SSO data. size_t short_length() const { assert(is_short()); - return short_rep.raw_size >> 1; + return static_cast<size_t>(short_rep.raw_size >> 1); } // Sets the length of the internal SSO data. @@ -412,8 +410,12 @@ class CordBuffer { // Power2 functions static bool IsPow2(size_t size) { return absl::has_single_bit(size); } - static size_t Log2Floor(size_t size) { return absl::bit_width(size) - 1; } - static size_t Log2Ceil(size_t size) { return absl::bit_width(size - 1); } + static size_t Log2Floor(size_t size) { + return static_cast<size_t>(absl::bit_width(size) - 1); + } + static size_t Log2Ceil(size_t size) { + return static_cast<size_t>(absl::bit_width(size - 1)); + } // Implementation of `CreateWithCustomLimit()`. // This implementation allows for future memory allocation hints to @@ -457,9 +459,7 @@ inline constexpr size_t CordBuffer::MaximumPayload() { } inline constexpr size_t CordBuffer::MaximumPayload(size_t block_size) { - // TODO(absl-team): Use std::min when C++11 support is dropped. - return (kCustomLimit < block_size ? kCustomLimit : block_size) - - cord_internal::kFlatOverhead; + return (std::min)(kCustomLimit, block_size) - cord_internal::kFlatOverhead; } inline CordBuffer CordBuffer::CreateWithDefaultLimit(size_t capacity) { |