diff options
Diffstat (limited to 'absl/strings/internal')
-rw-r--r-- | absl/strings/internal/char_map.h | 20 | ||||
-rw-r--r-- | absl/strings/internal/cord_internal.h | 2 | ||||
-rw-r--r-- | absl/strings/internal/str_format/parser.h | 8 |
3 files changed, 17 insertions, 13 deletions
diff --git a/absl/strings/internal/char_map.h b/absl/strings/internal/char_map.h index 61484de0..5aabc1fc 100644 --- a/absl/strings/internal/char_map.h +++ b/absl/strings/internal/char_map.h @@ -103,10 +103,9 @@ class Charmap { constexpr Charmap(uint64_t b0, uint64_t b1, uint64_t b2, uint64_t b3) : m_{b0, b1, b2, b3} {} - static constexpr uint64_t RangeForWord(unsigned char lo, unsigned char hi, - uint64_t word) { - return OpenRangeFromZeroForWord(hi + 1, word) & - ~OpenRangeFromZeroForWord(lo, word); + static constexpr uint64_t RangeForWord(char lo, char hi, uint64_t word) { + return OpenRangeFromZeroForWord(static_cast<unsigned char>(hi) + 1, word) & + ~OpenRangeFromZeroForWord(static_cast<unsigned char>(lo), word); } // All the chars in the specified word of the range [0, upper). @@ -119,13 +118,16 @@ class Charmap { : (~static_cast<uint64_t>(0) >> (64 - upper % 64)); } - static constexpr uint64_t CharMaskForWord(unsigned char x, uint64_t word) { - return (x / 64 == word) ? (static_cast<uint64_t>(1) << (x % 64)) : 0; + static constexpr uint64_t CharMaskForWord(char x, uint64_t word) { + const auto unsigned_x = static_cast<unsigned char>(x); + return (unsigned_x / 64 == word) + ? (static_cast<uint64_t>(1) << (unsigned_x % 64)) + : 0; } - private: - void SetChar(unsigned char c) { - m_[c / 64] |= static_cast<uint64_t>(1) << (c % 64); + void SetChar(char c) { + const auto unsigned_c = static_cast<unsigned char>(c); + m_[unsigned_c / 64] |= static_cast<uint64_t>(1) << (unsigned_c % 64); } uint64_t m_[4]; diff --git a/absl/strings/internal/cord_internal.h b/absl/strings/internal/cord_internal.h index b50fb79a..29954112 100644 --- a/absl/strings/internal/cord_internal.h +++ b/absl/strings/internal/cord_internal.h @@ -570,7 +570,7 @@ class InlineData { // Requires the current instance to hold inline data. size_t inline_size() const { assert(!is_tree()); - return tag() >> 1; + return static_cast<size_t>(tag()) >> 1; } // Sets the size of the inlined character data inside this instance. diff --git a/absl/strings/internal/str_format/parser.h b/absl/strings/internal/str_format/parser.h index 32b91d03..a81bac83 100644 --- a/absl/strings/internal/str_format/parser.h +++ b/absl/strings/internal/str_format/parser.h @@ -155,10 +155,11 @@ bool ParseFormatString(string_view src, Consumer consumer) { static_cast<const char*>(memchr(p, '%', static_cast<size_t>(end - p))); if (!percent) { // We found the last substring. - return consumer.Append(string_view(p, end - p)); + return consumer.Append(string_view(p, static_cast<size_t>(end - p))); } // We found a percent, so push the text run then process the percent. - if (ABSL_PREDICT_FALSE(!consumer.Append(string_view(p, percent - p)))) { + if (ABSL_PREDICT_FALSE(!consumer.Append( + string_view(p, static_cast<size_t>(percent - p))))) { return false; } if (ABSL_PREDICT_FALSE(percent + 1 >= end)) return false; @@ -189,7 +190,8 @@ bool ParseFormatString(string_view src, Consumer consumer) { p = ConsumeUnboundConversion(percent + 1, end, &conv, &next_arg); if (ABSL_PREDICT_FALSE(p == nullptr)) return false; if (ABSL_PREDICT_FALSE(!consumer.ConvertOne( - conv, string_view(percent + 1, p - (percent + 1))))) { + conv, string_view(percent + 1, + static_cast<size_t>(p - (percent + 1)))))) { return false; } } else { |