From 9e7faebf904ec2d7a697e033338efe340ec1101e Mon Sep 17 00:00:00 2001 From: Timofey Solomko Date: Thu, 21 Oct 2021 22:31:00 +0300 Subject: [PATCH] [LZ4] Don't use crc32 for matches identification --- Sources/LZ4/LZ4+Compress.swift | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/Sources/LZ4/LZ4+Compress.swift b/Sources/LZ4/LZ4+Compress.swift index 52f1138f..f27e0515 100644 --- a/Sources/LZ4/LZ4+Compress.swift +++ b/Sources/LZ4/LZ4+Compress.swift @@ -161,17 +161,17 @@ extension LZ4: CompressionAlgorithm { // are checked for this condition in the match-searching while-loop, but minmatches (4-bytes long) are verified // here (hence -9). while i < blockBytes.endIndex - 9 { - let matchCrc = CheckSums.crc32(Data(blockBytes[i..) -> UInt32 { + var result = 0 as UInt32 + for i in range { + result <<= 8 + result |= UInt32(truncatingIfNeeded: bytes[i]) + } + return result + } + }