diff options
author | Derek Mauro <dmauro@google.com> | 2022-11-29 09:19:04 -0800 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2022-11-29 09:19:57 -0800 |
commit | d03cced7d552ece168c6db92acb3a7c379aae0c0 (patch) | |
tree | f5975b279620e410ad017ee09bceaee4c676fec1 /absl/crc/internal | |
parent | 82196f059f213c50738142a799bb166b2971950d (diff) |
CRC: Make crc32c_t as a class for explicit control of operators
The motivation is to explicitly remove and document dangerous
operations like adding crc32c_t to a set, because equality is not
enough to guarantee uniqueness.
PiperOrigin-RevId: 491656425
Change-Id: I7b4dadc1a59ea9861e6ec7a929d64b5746467832
Diffstat (limited to 'absl/crc/internal')
-rw-r--r-- | absl/crc/internal/crc_memcpy.h | 4 | ||||
-rw-r--r-- | absl/crc/internal/crc_memcpy_test.cc | 4 |
2 files changed, 4 insertions, 4 deletions
diff --git a/absl/crc/internal/crc_memcpy.h b/absl/crc/internal/crc_memcpy.h index 8e728a6e..ae9cccad 100644 --- a/absl/crc/internal/crc_memcpy.h +++ b/absl/crc/internal/crc_memcpy.h @@ -40,7 +40,7 @@ class CrcMemcpy { public: static crc32c_t CrcAndCopy(void* __restrict dst, const void* __restrict src, std::size_t length, - crc32c_t initial_crc = ToCrc32c(0), + crc32c_t initial_crc = crc32c_t{0}, bool non_temporal = false) { static const ArchSpecificEngines engines = GetArchSpecificEngines(); auto* engine = non_temporal ? engines.non_temporal : engines.temporal; @@ -100,7 +100,7 @@ class CrcNonTemporalMemcpyAVXEngine : public CrcMemcpyEngine { // the generic fallback version. inline crc32c_t Crc32CAndCopy(void* __restrict dst, const void* __restrict src, std::size_t length, - crc32c_t initial_crc = ToCrc32c(0), + crc32c_t initial_crc = crc32c_t{0}, bool non_temporal = false) { return CrcMemcpy::CrcAndCopy(dst, src, length, initial_crc, non_temporal); } diff --git a/absl/crc/internal/crc_memcpy_test.cc b/absl/crc/internal/crc_memcpy_test.cc index 708e8666..bbdcd205 100644 --- a/absl/crc/internal/crc_memcpy_test.cc +++ b/absl/crc/internal/crc_memcpy_test.cc @@ -108,7 +108,7 @@ TEST_P(x86ParamTest, SmallCorrectnessCheckSourceAlignment) { static_cast<char>(absl::Uniform<unsigned char>(gen_)); } absl::crc32c_t initial_crc = - absl::ToCrc32c(absl::Uniform<uint32_t>(gen_)); + absl::crc32c_t{absl::Uniform<uint32_t>(gen_)}; absl::crc32c_t experiment_crc = engine_->Compute(destination_.get(), source_.get() + source_alignment, size, initial_crc); @@ -139,7 +139,7 @@ TEST_P(x86ParamTest, SmallCorrectnessCheckDestAlignment) { static_cast<char>(absl::Uniform<unsigned char>(gen_)); } absl::crc32c_t initial_crc = - absl::ToCrc32c(absl::Uniform<uint32_t>(gen_)); + absl::crc32c_t{absl::Uniform<uint32_t>(gen_)}; absl::crc32c_t experiment_crc = engine_->Compute(destination_.get() + dest_alignment, source_.get(), size, initial_crc); |