From 56bfed7e2cdd44dc4ad0c5e233224cf0080e05ac Mon Sep 17 00:00:00 2001 From: pacien Date: Sun, 2 Dec 2018 00:38:12 +0100 Subject: replace linkedlists by seqs --- src/lzsshuffman/lzsshuffmandecoder.nim | 7 +++---- src/lzsshuffman/lzsshuffmanencoder.nim | 5 ++--- src/lzsshuffman/lzsshuffmanstats.nim | 2 +- 3 files changed, 6 insertions(+), 8 deletions(-) (limited to 'src/lzsshuffman') diff --git a/src/lzsshuffman/lzsshuffmandecoder.nim b/src/lzsshuffman/lzsshuffmandecoder.nim index cd71914..a307774 100644 --- a/src/lzsshuffman/lzsshuffmandecoder.nim +++ b/src/lzsshuffman/lzsshuffmandecoder.nim @@ -14,9 +14,8 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -import lists import ../bitio/bitreader -import ../lzss/listpolyfill, ../lzss/lzssnode, ../lzss/lzsschain +import ../lzss/lzssnode, ../lzss/lzsschain import ../huffman/huffmantree, ../huffman/huffmandecoder import lzsshuffmansymbol @@ -26,9 +25,9 @@ proc readChain*(bitReader: BitReader, symbolDecoder, positionDecoder: HuffmanDec while not symbol.isEndMarker(): if byteCursor > maxDataByteLength: raise newException(IOError, "lzss block too long") if symbol.isCharacter(): - chain.append(lzssCharacter(symbol.uint8)) + chain.add(lzssCharacter(symbol.uint8)) else: let position = positionDecoder.decode(bitReader) - chain.append(unpackLzssReference(symbol, position)) + chain.add(unpackLzssReference(symbol, position)) (symbol, byteCursor) = (symbolDecoder.decode(bitReader).Symbol, byteCursor + 1) chain diff --git a/src/lzsshuffman/lzsshuffmanencoder.nim b/src/lzsshuffman/lzsshuffmanencoder.nim index ea89f85..205f464 100644 --- a/src/lzsshuffman/lzsshuffmanencoder.nim +++ b/src/lzsshuffman/lzsshuffmanencoder.nim @@ -14,9 +14,8 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -import lists import ../bitio/bitwriter -import ../lzss/listpolyfill, ../lzss/lzssnode, ../lzss/lzsschain, ../lzss/lzssencoder +import ../lzss/lzssnode, ../lzss/lzsschain, ../lzss/lzssencoder import ../huffman/huffmantree, ../huffman/huffmantreebuilder, ../huffman/huffmanencoder import lzsshuffmansymbol @@ -24,7 +23,7 @@ proc writeSymbol(bitWriter: BitWriter, encodedSymbol: tuple[bitLength: int, valu bitWriter.writeBits(encodedSymbol.bitLength, encodedSymbol.value) proc writeChain*(lzssChain: LzssChain, symbolEncoder, positionEncoder: HuffmanEncoder[uint16, uint16], bitWriter: BitWriter) = - for node in lzssChain.items: + for node in lzssChain: case node.kind: of character: bitWriter.writeSymbol(symbolEncoder.encode(node.character)) diff --git a/src/lzsshuffman/lzsshuffmanstats.nim b/src/lzsshuffman/lzsshuffmanstats.nim index 037ce5f..d5c1f3e 100644 --- a/src/lzsshuffman/lzsshuffmanstats.nim +++ b/src/lzsshuffman/lzsshuffmanstats.nim @@ -20,7 +20,7 @@ import lzsshuffmansymbol proc aggregateStats*(chain: LzssChain): tuple[symbolTable, positionTable: CountTableRef[uint16]] = var (symbolTable, positionTable) = (newCountTable[uint16](), newCountTable[uint16]()) - for node in chain.items: + for node in chain: case node.kind: of character: symbolTable.inc(node.character) -- cgit v1.2.3