From 2b47fb7f49a69bf9c1a06fc389d772e4bad0b515 Mon Sep 17 00:00:00 2001 From: Timofey Solomko Date: Sat, 21 May 2022 21:38:00 +0300 Subject: [PATCH] [Deflate] Replace computation of static tree codes from lenghts with precomputed codes --- Sources/Common/CodingTree/CodeLength.swift | 19 -- Sources/Common/CodingTree/EncodingTree.swift | 1 - Sources/Deflate/Deflate+Compress.swift | 5 +- Sources/Deflate/Deflate+Constants.swift | 172 ++++++++++++++++++- Sources/Deflate/Deflate.swift | 6 +- 5 files changed, 170 insertions(+), 33 deletions(-) diff --git a/Sources/Common/CodingTree/CodeLength.swift b/Sources/Common/CodingTree/CodeLength.swift index 74ca92f7..6d149758 100644 --- a/Sources/Common/CodingTree/CodeLength.swift +++ b/Sources/Common/CodingTree/CodeLength.swift @@ -10,25 +10,6 @@ struct CodeLength: Equatable { let symbol: Int let codeLength: Int - static func lengths(from bootstrap: [(symbol: Int, codeLength: Int)]) -> [CodeLength] { - // Fills the 'lengths' array with pairs of (symbol, codeLength) from a 'bootstrap'. - var lengths = [CodeLength]() - var start = bootstrap[0].symbol - var bits = bootstrap[0].codeLength - for pair in bootstrap[1.. 0 { - for i in start..