Anonymous user
LZW compression: Difference between revisions
m
Optimized Lua decompress using table.concat. On 1.2mb test data, ~44x faster. 58.8s to 1.3s
m (→{{header|Haskell}}: make the types more general) |
m (Optimized Lua decompress using table.concat. On 1.2mb test data, ~44x faster. 58.8s to 1.3s) |
||
Line 2,908:
local function decompress(compressed) -- table
local dictionary, dictSize, entry, result, w, k = {},
for i = 0, 255 do
dictionary[i] = string.char(i)
Line 2,921:
return nil, i
end
table.insert(result
dictionary[dictSize] = w .. string.sub(entry, 1, 1)
dictSize = dictSize + 1
w = entry
end
return table.concat(result)
end
|