A small cleanup in HuffmanTable initializer.

This commit is contained in:
Timofey Solomko
2016-11-13 19:10:55 +03:00
parent 480e7dfebc
commit d321856339
-10
View File
@@ -28,9 +28,6 @@ class HuffmanTable: CustomStringConvertible {
var lengths: [HuffmanLength]
let minBits: Int
let maxBits: Int
var description: String {
return self.lengths.reduce("HuffmanTable:\n") { $0.appending("\($1)\n") }
}
@@ -50,7 +47,6 @@ class HuffmanTable: CustomStringConvertible {
}
start = finish
bits = endbits
if endbits == -1 { break } // TODO: Check if this line is unnecessary
}
// Sort the lengths' array so finding of symbols will be more efficient
self.lengths = newLengths.sorted()
@@ -84,12 +80,6 @@ class HuffmanTable: CustomStringConvertible {
self.lengths[index].symbol = symbol
self.lengths[index].reversedSymbol = reverse(bits: loopBits, in: symbol)
}
// Finds minimum and maximum bits in the entire table of lengths
// TODO: Do we actually need this?
(self.minBits, self.maxBits) = self.lengths.reduce((16, -1)) {
return (min($0.0, $1.bits), max($0.1, $1.bits))
}
}
convenience init(lengthsToOrder: [Int]) {