Skip to content

Commit 742e436

Browse files
committed
Convert od constant table into packed bytes to save memory.
1 parent cd112c7 commit 742e436

1 file changed

Lines changed: 3 additions & 6 deletions

File tree

arch/INFLATE.LUA

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ function inflate(r, w, z)
6464
-- bs = bit stream
6565
-- op = output position
6666
-- kg = keep going (in a loop)
67-
-- sw = sliding window (32KB circular buffer)
67+
-- sw = sliding window (32/64KB buffer)
6868
-- wp = window pointer
6969
-- o = output chunk buffer
7070
local bs, op, kg, sw, wp, o = nbs(r), 0, 1, {}, 0, {}
@@ -153,9 +153,6 @@ function inflate(r, w, z)
153153
error("!Huffman", 0)
154154
end
155155

156-
---Append string
157-
function as(s) for i = 1, #s do ab(s:byte(i)) end end
158-
159156
while kg > 0 do
160157

161158
-- f = final
@@ -196,10 +193,10 @@ function inflate(r, w, z)
196193
-- cl = clen
197194
-- le = lens
198195
-- ch = chuff
199-
local hl, hd, hc, od, cl, le, ch = bs.r(5) + 257, bs.r(5) + 1, bs.r(4) + 4, {16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15}, {}, {}
196+
local hl, hd, hc, od, cl, le, ch = bs.r(5) + 257, bs.r(5) + 1, bs.r(4) + 4, "\016\017\018\000\008\007\009\006\010\005\011\004\012\003\013\002\014\001\015", {}, {}
200197

201198
for i = 1, 19 do cl[i] = 0 end
202-
for i = 1, hc do cl[od[i] + 1] = bs.r(3) end
199+
for i = 1, hc do cl[od:byte(i) + 1] = bs.r(3) end
203200
ch = mh(cl)
204201

205202
while #le < hl + hd do

0 commit comments

Comments
 (0)