perf: zstd sequence extra bits and state updates read inline
This commit is contained in:
1 parent
4eca395b00
commit
dbca9d5670
1 file changed
+36
-10
@@ -659,14 +659,24 @@ local function block(b: buffer, p: number, e: number, st: any): (string?, string
|
||||
local ml = ML_BASE[mlCode]
|
||||
local nb = ML_BITS[mlCode]
|
||||
if nb > 0 then
|
||||
ml += peek(b, s, off, nb)
|
||||
off -= nb
|
||||
local lo = off - nb
|
||||
if lo >= 0 and s + rshift(lo, 3) <= fastEnd then
|
||||
ml += band(rshift(readu32(b, s + rshift(lo, 3)), band(lo, 7)), lshift(1, nb) - 1)
|
||||
else
|
||||
ml += peek(b, s, off, nb)
|
||||
end
|
||||
off = lo
|
||||
end
|
||||
local ll = LL_BASE[llCode]
|
||||
nb = LL_BITS[llCode]
|
||||
if nb > 0 then
|
||||
ll += peek(b, s, off, nb)
|
||||
off -= nb
|
||||
local lo = off - nb
|
||||
if lo >= 0 and s + rshift(lo, 3) <= fastEnd then
|
||||
ll += band(rshift(readu32(b, s + rshift(lo, 3)), band(lo, 7)), lshift(1, nb) - 1)
|
||||
else
|
||||
ll += peek(b, s, off, nb)
|
||||
end
|
||||
off = lo
|
||||
end
|
||||
-- repeat offsets
|
||||
local offset
|
||||
@@ -699,15 +709,31 @@ local function block(b: buffer, p: number, e: number, st: any): (string?, string
|
||||
end
|
||||
-- state updates (not after the last sequence): LL, ML, OF
|
||||
if i < nbSeq then
|
||||
local lo
|
||||
nb = band(rshift(llE, 8), 255)
|
||||
llS = rshift(llE, 16) + peek(b, s, off, nb)
|
||||
off -= nb
|
||||
lo = off - nb
|
||||
if lo >= 0 and s + rshift(lo, 3) <= fastEnd then
|
||||
llS = rshift(llE, 16) + band(rshift(readu32(b, s + rshift(lo, 3)), band(lo, 7)), lshift(1, nb) - 1)
|
||||
else
|
||||
llS = rshift(llE, 16) + peek(b, s, off, nb)
|
||||
end
|
||||
off = lo
|
||||
nb = band(rshift(mlE, 8), 255)
|
||||
mlS = rshift(mlE, 16) + peek(b, s, off, nb)
|
||||
off -= nb
|
||||
lo = off - nb
|
||||
if lo >= 0 and s + rshift(lo, 3) <= fastEnd then
|
||||
mlS = rshift(mlE, 16) + band(rshift(readu32(b, s + rshift(lo, 3)), band(lo, 7)), lshift(1, nb) - 1)
|
||||
else
|
||||
mlS = rshift(mlE, 16) + peek(b, s, off, nb)
|
||||
end
|
||||
off = lo
|
||||
nb = band(rshift(ofE, 8), 255)
|
||||
ofS = rshift(ofE, 16) + peek(b, s, off, nb)
|
||||
off -= nb
|
||||
lo = off - nb
|
||||
if lo >= 0 and s + rshift(lo, 3) <= fastEnd then
|
||||
ofS = rshift(ofE, 16) + band(rshift(readu32(b, s + rshift(lo, 3)), band(lo, 7)), lshift(1, nb) - 1)
|
||||
else
|
||||
ofS = rshift(ofE, 16) + peek(b, s, off, nb)
|
||||
end
|
||||
off = lo
|
||||
end
|
||||
-- execute
|
||||
if lp + ll > litEnd then
|
||||
|
||||
Reference in new issue
Block a user