[LZMA2] Use LZMAProperties.updateDictionarySize function in LZMA2 decoder

This commit is contained in:
Timofey Solomko
2018-08-22 10:40:16 +03:00
parent 30f46e06db
commit bceb10db9f
+1 -15
View File
@@ -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.