diff options
author | Copybara-Service <copybara-worker@google.com> | 2023-03-08 12:09:34 -0800 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2023-03-08 12:09:34 -0800 |
commit | d5d287dc28f0f3cef52928e9e8fe6f29f6577d63 (patch) | |
tree | 598bafaa915df933cb8b9764b927fcbdcc441621 /absl | |
parent | 297efcc96b259a706f5cd7dd51e399f1d5f23f9d (diff) | |
parent | b13195f2dc9a815e8128c8bbd37cf2f4400b4541 (diff) |
Merge pull request #1395 from AtariDreams:const
PiperOrigin-RevId: 515105001
Change-Id: I4a8ce8291ef3df23108dd21d8adb6752cde92dd0
Diffstat (limited to 'absl')
-rw-r--r-- | absl/crc/internal/crc.cc | 4 | ||||
-rw-r--r-- | absl/crc/internal/crc_internal.h | 6 | ||||
-rw-r--r-- | absl/strings/cord_buffer.h | 3 | ||||
-rw-r--r-- | absl/strings/internal/str_format/float_conversion.cc | 2 | ||||
-rw-r--r-- | absl/strings/str_split.cc | 15 |
5 files changed, 16 insertions, 14 deletions
diff --git a/absl/crc/internal/crc.cc b/absl/crc/internal/crc.cc index 337a173f..87202165 100644 --- a/absl/crc/internal/crc.cc +++ b/absl/crc/internal/crc.cc @@ -261,7 +261,7 @@ void CRC32::Extend(uint32_t* crc, const void* bytes, size_t length) const { const uint8_t* e = p + length; uint32_t l = *crc; - auto step_one_byte = [this, &p, &l] () { + auto step_one_byte = [this, &p, &l]() { int c = (l & 0xff) ^ *p++; l = this->table0_[c] ^ (l >> 8); }; @@ -359,7 +359,7 @@ void CRC32::Extend(uint32_t* crc, const void* bytes, size_t length) const { void CRC32::ExtendByZeroesImpl(uint32_t* crc, size_t length, const uint32_t zeroes_table[256], - const uint32_t poly_table[256]) const { + const uint32_t poly_table[256]) { if (length != 0) { uint32_t l = *crc; // For each ZEROES_BASE_LG bits in length diff --git a/absl/crc/internal/crc_internal.h b/absl/crc/internal/crc_internal.h index 9f080913..3a047880 100644 --- a/absl/crc/internal/crc_internal.h +++ b/absl/crc/internal/crc_internal.h @@ -118,9 +118,9 @@ class CRC32 : public CRCImpl { // // These will be set to reverse_zeroes_ and reverse_table0_ for Unextend, and // CRC32::zeroes_ and CRC32::table0_ for Extend. - void ExtendByZeroesImpl(uint32_t* crc, size_t length, - const uint32_t zeroes_table[256], - const uint32_t poly_table[256]) const; + static void ExtendByZeroesImpl(uint32_t* crc, size_t length, + const uint32_t zeroes_table[256], + const uint32_t poly_table[256]); uint32_t table0_[256]; // table of byte extensions uint32_t zeroes_[256]; // table of zero extensions diff --git a/absl/strings/cord_buffer.h b/absl/strings/cord_buffer.h index a3600ac4..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 @@ -336,7 +335,7 @@ class CordBuffer { } // 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, diff --git a/absl/strings/internal/str_format/float_conversion.cc b/absl/strings/internal/str_format/float_conversion.cc index fe0ad4bd..f1490e5a 100644 --- a/absl/strings/internal/str_format/float_conversion.cc +++ b/absl/strings/internal/str_format/float_conversion.cc @@ -1015,7 +1015,7 @@ struct Buffer { --end; } - char &back() { + char &back() const { assert(begin < end); return end[-1]; } diff --git a/absl/strings/str_split.cc b/absl/strings/str_split.cc index e08c26b6..72ba7c02 100644 --- a/absl/strings/str_split.cc +++ b/absl/strings/str_split.cc @@ -60,19 +60,23 @@ absl::string_view GenericFind(absl::string_view text, // Finds using absl::string_view::find(), therefore the length of the found // delimiter is delimiter.length(). struct LiteralPolicy { - size_t Find(absl::string_view text, absl::string_view delimiter, size_t pos) { + static size_t Find(absl::string_view text, absl::string_view delimiter, + size_t pos) { return text.find(delimiter, pos); } - size_t Length(absl::string_view delimiter) { return delimiter.length(); } + static size_t Length(absl::string_view delimiter) { + return delimiter.length(); + } }; // Finds using absl::string_view::find_first_of(), therefore the length of the // found delimiter is 1. struct AnyOfPolicy { - size_t Find(absl::string_view text, absl::string_view delimiter, size_t pos) { + static size_t Find(absl::string_view text, absl::string_view delimiter, + size_t pos) { return text.find_first_of(delimiter, pos); } - size_t Length(absl::string_view /* delimiter */) { return 1; } + static size_t Length(absl::string_view /* delimiter */) { return 1; } }; } // namespace @@ -123,8 +127,7 @@ ByLength::ByLength(ptrdiff_t length) : length_(length) { ABSL_RAW_CHECK(length > 0, ""); } -absl::string_view ByLength::Find(absl::string_view text, - size_t pos) const { +absl::string_view ByLength::Find(absl::string_view text, size_t pos) const { pos = std::min(pos, text.size()); // truncate `pos` absl::string_view substr = text.substr(pos); // If the string is shorter than the chunk size we say we |