From bceb10db9fafa33be0be40df76a4f56cadd70eb3 Mon Sep 17 00:00:00 2001 From: Timofey Solomko Date: Mon, 13 Aug 2018 23:56:07 +0300 Subject: [PATCH] [LZMA2] Use LZMAProperties.updateDictionarySize function in LZMA2 decoder --- Sources/LZMA2/LZMA2Decoder.swift | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/Sources/LZMA2/LZMA2Decoder.swift b/Sources/LZMA2/LZMA2Decoder.swift index 7ae7609f..c55e964a 100644 --- a/Sources/LZMA2/LZMA2Decoder.swift +++ b/Sources/LZMA2/LZMA2Decoder.swift @@ -21,21 +21,7 @@ final class LZMA2Decoder { } func setDictionarySize(_ byte: UInt8) throws { - guard byte & 0xC0 == 0 - else { throw LZMA2Error.wrongDictionarySize } - let bits = (byte & 0x3F).toInt() - guard bits < 40 - else { throw LZMA2Error.wrongDictionarySize } - - var dictSize: UInt32 - if bits == 40 { - dictSize = UInt32.max - } else { - dictSize = UInt32(truncatingIfNeeded: 2 | (bits & 1)) - dictSize <<= UInt32(truncatingIfNeeded: bits / 2 + 11) - } - - self.decoder.properties.dictionarySize = dictSize.toInt() + try self.decoder.properties.updateDictionarySize(lzma2Byte: byte) } /// Main LZMA2 decoder function.