formatting
This commit is contained in:
parent
102fca266a
commit
a50985ff8d
|
@ -1,7 +1,7 @@
|
|||
import httpclient, zippy, strformat
|
||||
import httpclient, strformat, zippy
|
||||
|
||||
let client = newHttpClient()
|
||||
client.headers = newHttpHeaders({ "Accept-Encoding": "gzip" })
|
||||
client.headers = newHttpHeaders({"Accept-Encoding": "gzip"})
|
||||
|
||||
let
|
||||
response = client.request("http://www.google.com")
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import asynchttpserver, asyncdispatch, zippy
|
||||
import asyncdispatch, asynchttpserver, zippy
|
||||
|
||||
let server = newAsyncHttpServer()
|
||||
|
||||
proc cb(req: Request) {.async.} =
|
||||
if req.headers["Accept-Encoding"].contains("gzip"):
|
||||
# This client supports gzip, send compressed response
|
||||
let headers = newHttpHeaders([("Content-Encoding","gzip")])
|
||||
let headers = newHttpHeaders([("Content-Encoding", "gzip")])
|
||||
await req.respond(
|
||||
Http200,
|
||||
compress("gzip'ed response body", dfGzip),
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
const
|
||||
maxCodeLength* = 15 ## Maximum bits in a code
|
||||
maxCodeLength* = 15 ## Maximum bits in a code
|
||||
maxLitLenCodes* = 286
|
||||
maxDistCodes* = 30
|
||||
maxFixedLitLenCodes* = 288
|
||||
|
|
|
@ -234,7 +234,7 @@ func lz77Encode(src: seq[uint8]): (seq[uint16], seq[int], seq[int], int) =
|
|||
var
|
||||
pos, literalLen: int
|
||||
windowPos, hash: uint16
|
||||
head = newSeq[uint16](hashSize) # hash -> pos
|
||||
head = newSeq[uint16](hashSize) # hash -> pos
|
||||
chain = newSeq[uint16](windowSize) # pos a -> pos b
|
||||
|
||||
template updateHash(value: uint8) =
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import strformat, strutils, fidget/opengl/perf
|
||||
import fidget/opengl/perf, strformat, strutils
|
||||
|
||||
const
|
||||
minMatchLen = 3
|
||||
|
@ -47,7 +47,7 @@ proc lz77Encode2(src: seq[uint8]): seq[uint16] =
|
|||
var
|
||||
pos, literalLen: int
|
||||
windowPos, hash: uint16
|
||||
head = newSeq[uint16](hashSize) # hash -> pos
|
||||
head = newSeq[uint16](hashSize) # hash -> pos
|
||||
chain = newSeq[uint16](windowSize) # pos a -> pos b
|
||||
|
||||
template updateHash(value: uint8) =
|
||||
|
@ -82,12 +82,11 @@ proc lz77Encode2(src: seq[uint8]): seq[uint16] =
|
|||
break
|
||||
inc chainLen
|
||||
|
||||
let offset = (
|
||||
if hashPos <= windowPos:
|
||||
windowPos - hashPos
|
||||
else:
|
||||
windowPos - hashPos + windowSize
|
||||
).int
|
||||
var offset: int
|
||||
if hashPos <= windowPos:
|
||||
offset = (windowPos - hashPos).int
|
||||
else:
|
||||
offset = (windowPos - hashPos + windowSize).int
|
||||
|
||||
if offset <= 0 or offset < prevOffset:
|
||||
break
|
||||
|
@ -136,7 +135,7 @@ proc lz77Decode2(src: seq[uint8], encoded: seq[uint16]): seq[uint8] =
|
|||
var ip, op: int
|
||||
while ip < encoded.len:
|
||||
if op >= result.len:
|
||||
result.setLen(result.len * 2)
|
||||
result.setLen(result.len * 2)
|
||||
|
||||
if encoded[ip] == uint16.high:
|
||||
let
|
||||
|
|
Loading…
Reference in New Issue