mirror of
https://github.com/Relintai/MemR.git
synced 2024-12-23 14:06:54 +01:00
Cleanups.
This commit is contained in:
parent
38ac3c7b7d
commit
ec7686a450
@ -183,6 +183,7 @@ func decompress_lzw(code_stream_data: PoolByteArray, min_code_size: int, colors:
|
||||
prevcode = code
|
||||
elif code == clear_code_index + 1: # Stop when detected EOI Code.
|
||||
break
|
||||
|
||||
# is CODE in the code table?
|
||||
var code_entry: CodeEntry = code_table.get(code)
|
||||
if code_entry != null: # if YES
|
||||
@ -193,35 +194,20 @@ func decompress_lzw(code_stream_data: PoolByteArray, min_code_size: int, colors:
|
||||
# warning-ignore:return_value_discarded
|
||||
# add {PREVCODE} + k to the code table
|
||||
var prev_code_entry: CodeEntry = code_table.get(prevcode)
|
||||
|
||||
if prev_code_entry:
|
||||
code_table.add(prev_code_entry.add(k))
|
||||
else:
|
||||
code_table.add(k)
|
||||
# set PREVCODE = CODE
|
||||
prevcode = code
|
||||
else: # if NO
|
||||
# let k be the first index of {PREVCODE}
|
||||
var prevcode_entry: CodeEntry = code_table.get(prevcode)
|
||||
|
||||
var k: CodeEntry
|
||||
|
||||
if prevcode_entry:
|
||||
k = CodeEntry.new([prevcode_entry.sequence[0]])
|
||||
else:
|
||||
k = CodeEntry.new([ code ])
|
||||
|
||||
var k: CodeEntry = CodeEntry.new([prevcode_entry.sequence[0]])
|
||||
# output {PREVCODE} + k to index stream
|
||||
index_stream.append_array(prevcode_entry.add(k).sequence)
|
||||
# output {PREVCODE} + k to index stream
|
||||
if prevcode_entry:
|
||||
index_stream.append_array(prevcode_entry.add(k).sequence)
|
||||
else:
|
||||
index_stream.append_array(k.sequence)
|
||||
# add {PREVCODE} + k to code table
|
||||
# warning-ignore:return_value_discarded
|
||||
if prevcode_entry:
|
||||
code_table.add(prevcode_entry.add(k))
|
||||
else:
|
||||
code_table.add(k)
|
||||
# set PREVCODE = CODE
|
||||
prevcode = code
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user