From d03cced7d552ece168c6db92acb3a7c379aae0c0 Mon Sep 17 00:00:00 2001 From: Derek Mauro Date: Tue, 29 Nov 2022 09:19:04 -0800 Subject: 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 --- absl/crc/internal/crc_memcpy.h | 4 ++-- absl/crc/internal/crc_memcpy_test.cc | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'absl/crc/internal') 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(absl::Uniform(gen_)); } absl::crc32c_t initial_crc = - absl::ToCrc32c(absl::Uniform(gen_)); + absl::crc32c_t{absl::Uniform(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(absl::Uniform(gen_)); } absl::crc32c_t initial_crc = - absl::ToCrc32c(absl::Uniform(gen_)); + absl::crc32c_t{absl::Uniform(gen_)}; absl::crc32c_t experiment_crc = engine_->Compute(destination_.get() + dest_alignment, source_.get(), size, initial_crc); -- cgit v1.2.3