diff --git a/.jazzy.yaml b/.jazzy.yaml index 2a57f2b1..2a023beb 100644 --- a/.jazzy.yaml +++ b/.jazzy.yaml @@ -3,11 +3,11 @@ sourcekitten_sourcefile: docs.json clean: true author: Timofey Solomko module: SWCompression -module_version: 4.5.9 +module_version: 4.5.10 copyright: '© 2021 Timofey Solomko' readme: README.md github_url: https://github.com/tsolomko/SWCompression -github_file_prefix: https://github.com/tsolomko/SWCompression/tree/4.5.9 +github_file_prefix: https://github.com/tsolomko/SWCompression/tree/4.5.10 theme: fullwidth custom_categories: diff --git a/CHANGELOG.md b/CHANGELOG.md index 989429ba..d28dce1b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## 4.5.10 + +- Fixed compilation issues on Windows (PR #22 by @trametheka). +- Performed minor optimizations to BZip2 and Deflate compression functionality. +- Increased the lowest required version of BitByteData dependency to 1.4.4. + ## 4.5.9 - Improved performance of LZMA/LZMA2 and, consequently, of XZ. diff --git a/SWCompression.podspec b/SWCompression.podspec index 4f10dc40..21773455 100644 --- a/SWCompression.podspec +++ b/SWCompression.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |s| s.name = "SWCompression" - s.version = "4.5.9" + s.version = "4.5.10" s.summary = "A framework with functions for working with compression, archives and containers." s.description = "A framework with (de)compression algorithms and functions for processing various archives and containers." @@ -22,7 +22,7 @@ Pod::Spec.new do |s| s.swift_versions = ["5"] - s.dependency "BitByteData", "~> 1.4.3" + s.dependency "BitByteData", "~> 1.4.4" s.subspec "Deflate" do |sp| sp.source_files = "Sources/{Deflate/*,Common/*,Common/CodingTree/*}.swift" diff --git a/SWCompression.xcodeproj/SWCompression.plist b/SWCompression.xcodeproj/SWCompression.plist index ccfd150a..dc55faec 100644 --- a/SWCompression.xcodeproj/SWCompression.plist +++ b/SWCompression.xcodeproj/SWCompression.plist @@ -15,9 +15,9 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 4.5.9 + 4.5.10 CFBundleVersion - 76 + 77 NSHumanReadableCopyright Copyright © 2021 Timofey Solomko diff --git a/SWCompression.xcodeproj/TestSWCompression.plist b/SWCompression.xcodeproj/TestSWCompression.plist index fbfd44a0..1b2400fd 100644 --- a/SWCompression.xcodeproj/TestSWCompression.plist +++ b/SWCompression.xcodeproj/TestSWCompression.plist @@ -15,8 +15,8 @@ CFBundlePackageType BNDL CFBundleShortVersionString - 4.5.9 + 4.5.10 CFBundleVersion - 76 + 77 diff --git a/SWCompression.xcodeproj/project.pbxproj b/SWCompression.xcodeproj/project.pbxproj index 0086e555..9a4dae45 100644 --- a/SWCompression.xcodeproj/project.pbxproj +++ b/SWCompression.xcodeproj/project.pbxproj @@ -1258,7 +1258,7 @@ CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - CURRENT_PROJECT_VERSION = 76; + CURRENT_PROJECT_VERSION = 77; DEBUG_INFORMATION_FORMAT = dwarf; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; @@ -1339,7 +1339,7 @@ CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - CURRENT_PROJECT_VERSION = 76; + CURRENT_PROJECT_VERSION = 77; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; ENABLE_STRICT_OBJC_MSGSEND = YES; "FRAMEWORK_SEARCH_PATHS[sdk=appletvos*]" = ( @@ -1400,7 +1400,7 @@ APPLICATION_EXTENSION_API_ONLY = YES; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 76; + DYLIB_CURRENT_VERSION = 77; DYLIB_INSTALL_NAME_BASE = "@rpath"; INFOPLIST_FILE = SWCompression.xcodeproj/SWCompression.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; @@ -1427,7 +1427,7 @@ APPLICATION_EXTENSION_API_ONLY = YES; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 76; + DYLIB_CURRENT_VERSION = 77; DYLIB_INSTALL_NAME_BASE = "@rpath"; INFOPLIST_FILE = SWCompression.xcodeproj/SWCompression.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; diff --git a/Sources/BZip2/BZip2+Compress.swift b/Sources/BZip2/BZip2+Compress.swift index 96af5b3d..d46d764e 100644 --- a/Sources/BZip2/BZip2+Compress.swift +++ b/Sources/BZip2/BZip2+Compress.swift @@ -79,10 +79,8 @@ extension BZip2: CompressionAlgorithm { (out, pointer) = BurrowsWheeler.transform(bytes: out) let usedBytes = Set(out).sorted() - out = mtf(out, characters: usedBytes) - var maxSymbol = 0 - (out, maxSymbol) = rleOfMtf(out) + (out, maxSymbol) = mtfRle(out, characters: usedBytes) // First, we analyze data and create Huffman trees and selectors. // Then we will perform encoding itself. @@ -258,12 +256,16 @@ extension BZip2: CompressionAlgorithm { return out } - private static func rleOfMtf(_ array: [Int]) -> ([Int], Int) { + private static func mtfRle(_ array: [Int], characters: [Int]) -> ([Int], Int) { var out = [Int]() + /// Mutable copy of `characters`. + var dictionary = characters var lengthOfZerosRun = 0 var maxSymbol = 1 for i in 0.. -1 + guard codingIndex.treeCode > -1 else { fatalError("Symbol is not found.") } - self.bitWriter.write(number: codingIndex[0], bitsCount: codingIndex[1]) + self.bitWriter.write(number: codingIndex.treeCode, bitsCount: codingIndex.bitSize) } func bitSize(for stats: [Int]) -> Int { @@ -45,10 +52,10 @@ final class EncodingTree { guard symbol < self.codingIndices.count else { fatalError("Symbol is not found.") } let codingIndex = self.codingIndices[symbol] - guard codingIndex[0] > -1 + guard codingIndex.treeCode > -1 else { fatalError("Symbol is not found.") } - totalSize += count * codingIndex[1] + totalSize += count * codingIndex.bitSize } return totalSize } diff --git a/Sources/swcomp/main.swift b/Sources/swcomp/main.swift index 5ca7c1c9..16d1931f 100644 --- a/Sources/swcomp/main.swift +++ b/Sources/swcomp/main.swift @@ -7,7 +7,7 @@ import Foundation import SWCompression import SwiftCLI -let cli = CLI(name: "swcomp", version: "4.5.9", +let cli = CLI(name: "swcomp", version: "4.5.10", description: """ swcomp - a small command-line client for SWCompression framework. Serves as an example of SWCompression usage.