fixed-deflate ( bytes -- compressed )


Vocabulary
compression.deflate.private

Inputs
bytesan object


Outputs
compressedan object


Definition


:: fixed-deflate ( bytes -- compressed )
<deflate-writer> :> writer 3 3 writer write-bits
65536 f <array> :> positions 0 :> i!
[ i bytes length < ] [
0 :> n! 0 :> distance! i 2 + bytes length < [
i bytes prefix-hash :> hash hash positions nth
:> previous previous [
i previous - distance! distance 32768 <=
[ i previous bytes match-length n! ] when
] when
] when n 3 >=
[ n distance writer write-match ]
[ i bytes nth writer write-literal 1 n! ] if n [| j |
i j + :> pos pos 2 + bytes length <
[ pos pos bytes prefix-hash positions set-nth ] when
] each-integer i n + i!
] while 256 writer write-literal writer finish-bits ;