From 739d89919b1bd0413ffb1da5e9862039e74913f6 Mon Sep 17 00:00:00 2001 From: taylorswift Date: Wed, 3 Apr 2024 22:29:40 +0000 Subject: [PATCH] we should not emit checksums on *every* push --- Sources/LZ77/Deflator/LZ77.DeflatorBuffers.Stream.swift | 2 +- Sources/LZ77/Deflator/LZ77.DeflatorBuffers.swift | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Sources/LZ77/Deflator/LZ77.DeflatorBuffers.Stream.swift b/Sources/LZ77/Deflator/LZ77.DeflatorBuffers.Stream.swift index 3dddf6cb..cfae46a1 100644 --- a/Sources/LZ77/Deflator/LZ77.DeflatorBuffers.Stream.swift +++ b/Sources/LZ77/Deflator/LZ77.DeflatorBuffers.Stream.swift @@ -436,7 +436,7 @@ extension LZ77.DeflatorBuffers.Stream } /// Emits a dynamic (type = 2) DEFLATE block. - mutating + private mutating func writeBlock(final:Bool = false) { let tree: diff --git a/Sources/LZ77/Deflator/LZ77.DeflatorBuffers.swift b/Sources/LZ77/Deflator/LZ77.DeflatorBuffers.swift index 9ab0cd0d..c5061cde 100644 --- a/Sources/LZ77/Deflator/LZ77.DeflatorBuffers.swift +++ b/Sources/LZ77/Deflator/LZ77.DeflatorBuffers.swift @@ -80,7 +80,8 @@ extension LZ77.DeflatorBuffers self.stream.compressBlocks(final: last) - guard case .zlib = self.format + guard last, + case .zlib = self.format else { return @@ -123,6 +124,12 @@ extension LZ77.DeflatorBuffers self.stream.compressBlocks(final: last) + guard last + else + { + return + } + let checksum:UInt32 = self.stream.input.checksum() let bytes:UInt32 = self.stream.input.integral.bytes self.stream.writeLittleEndianUInt32(checksum)