From dfc7f46d9c8425933ffe2c275f982f956d33d06f Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Mon, 12 Jun 2023 13:43:18 -0700 Subject: Removes unused methods CRC::Empty() and CRC::Concat() from the internal implementation. PiperOrigin-RevId: 539749773 Change-Id: Iec83431ffd360a077b153cea00427580ae287d1f --- absl/crc/internal/crc.cc | 31 ------------------------------- absl/crc/internal/crc.h | 8 -------- absl/crc/internal/crc_internal.h | 2 -- 3 files changed, 41 deletions(-) diff --git a/absl/crc/internal/crc.cc b/absl/crc/internal/crc.cc index ba4c6d13..22e91c53 100644 --- a/absl/crc/internal/crc.cc +++ b/absl/crc/internal/crc.cc @@ -176,9 +176,6 @@ CRCImpl* CRCImpl::NewInternal() { return result; } -// The CRC of the empty string is always the CRC polynomial itself. -void CRCImpl::Empty(uint32_t* crc) const { *crc = kCrc32cPoly; } - // The 32-bit implementation void CRC32::InitTables() { @@ -435,34 +432,6 @@ CRC* CRC::Crc32c() { return singleton; } -// This Concat implementation works for arbitrary polynomials. -void CRC::Concat(uint32_t* px, uint32_t y, size_t ylen) { - // https://en.wikipedia.org/wiki/Mathematics_of_cyclic_redundancy_checks - // The CRC of a message M is the remainder of polynomial division modulo G, - // where the coefficient arithmetic is performed modulo 2 (so +/- are XOR): - // R(x) = M(x) x**n (mod G) - // (n is the degree of G) - // In practice, we use an initial value A and a bitmask B to get - // R = (A ^ B)x**|M| ^ Mx**n ^ B (mod G) - // If M is the concatenation of two strings S and T, and Z is the string of - // len(T) 0s, then the remainder CRC(ST) can be expressed as: - // R = (A ^ B)x**|ST| ^ STx**n ^ B - // = (A ^ B)x**|SZ| ^ SZx**n ^ B ^ Tx**n - // = CRC(SZ) ^ Tx**n - // CRC(Z) = (A ^ B)x**|T| ^ B - // CRC(T) = (A ^ B)x**|T| ^ Tx**n ^ B - // So R = CRC(SZ) ^ CRC(Z) ^ CRC(T) - // - // And further, since CRC(SZ) = Extend(CRC(S), Z), - // CRC(SZ) ^ CRC(Z) = Extend(CRC(S) ^ CRC(''), Z). - uint32_t z; - uint32_t t; - Empty(&z); - t = *px ^ z; - ExtendByZeroes(&t, ylen); - *px = t ^ y; -} - } // namespace crc_internal ABSL_NAMESPACE_END } // namespace absl diff --git a/absl/crc/internal/crc.h b/absl/crc/internal/crc.h index e683c25f..4efdd032 100644 --- a/absl/crc/internal/crc.h +++ b/absl/crc/internal/crc.h @@ -40,9 +40,6 @@ class CRC { public: virtual ~CRC(); - // Place the CRC of the empty string in "*crc" - virtual void Empty(uint32_t* crc) const = 0; - // If "*crc" is the CRC of bytestring A, place the CRC of // the bytestring formed from the concatenation of A and the "length" // bytes at "bytes" into "*crc". @@ -58,11 +55,6 @@ class CRC { // with those zero bytes removed. virtual void UnextendByZeroes(uint32_t* crc, size_t length) const = 0; - // If *px is the CRC (as defined by *crc) of some string X, - // and y is the CRC of some string Y that is ylen bytes long, set - // *px to the CRC of the concatenation of X followed by Y. - virtual void Concat(uint32_t* px, uint32_t y, size_t ylen); - // Apply a non-linear transformation to "*crc" so that // it is safe to CRC the result with the same polynomial without // any reduction of error-detection ability in the outer CRC. diff --git a/absl/crc/internal/crc_internal.h b/absl/crc/internal/crc_internal.h index 7d77bdf5..4d3582d9 100644 --- a/absl/crc/internal/crc_internal.h +++ b/absl/crc/internal/crc_internal.h @@ -70,8 +70,6 @@ class CRCImpl : public CRC { // Implementation of the abstract class CRC // The internal version of CRC::New(). static CRCImpl* NewInternal(); - void Empty(uint32_t* crc) const override; - // Fill in a table for updating a CRC by one word of 'word_size' bytes // [last_lo, last_hi] contains the answer if the last bit in the word // is set. -- cgit v1.2.3