Skip to content

Commit a50985f

Browse files
committed
formatting
1 parent 102fca2 commit a50985f

File tree

5 files changed

+14
-15
lines changed

5 files changed

+14
-15
lines changed

examples/http_client.nim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import httpclient, zippy, strformat
1+
import httpclient, strformat, zippy
22

33
let client = newHttpClient()
4-
client.headers = newHttpHeaders({ "Accept-Encoding": "gzip" })
4+
client.headers = newHttpHeaders({"Accept-Encoding": "gzip"})
55

66
let
77
response = client.request("http://www.google.com")

examples/http_server.nim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import asynchttpserver, asyncdispatch, zippy
1+
import asyncdispatch, asynchttpserver, zippy
22

33
let server = newAsyncHttpServer()
44

55
proc cb(req: Request) {.async.} =
66
if req.headers["Accept-Encoding"].contains("gzip"):
77
# This client supports gzip, send compressed response
8-
let headers = newHttpHeaders([("Content-Encoding","gzip")])
8+
let headers = newHttpHeaders([("Content-Encoding", "gzip")])
99
await req.respond(
1010
Http200,
1111
compress("gzip'ed response body", dfGzip),

src/zippy/common.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const
2-
maxCodeLength* = 15 ## Maximum bits in a code
2+
maxCodeLength* = 15 ## Maximum bits in a code
33
maxLitLenCodes* = 286
44
maxDistCodes* = 30
55
maxFixedLitLenCodes* = 288

src/zippy/deflate.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ func lz77Encode(src: seq[uint8]): (seq[uint16], seq[int], seq[int], int) =
234234
var
235235
pos, literalLen: int
236236
windowPos, hash: uint16
237-
head = newSeq[uint16](hashSize) # hash -> pos
237+
head = newSeq[uint16](hashSize) # hash -> pos
238238
chain = newSeq[uint16](windowSize) # pos a -> pos b
239239

240240
template updateHash(value: uint8) =

tests/lz77.nim

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import strformat, strutils, fidget/opengl/perf
1+
import fidget/opengl/perf, strformat, strutils
22

33
const
44
minMatchLen = 3
@@ -47,7 +47,7 @@ proc lz77Encode2(src: seq[uint8]): seq[uint16] =
4747
var
4848
pos, literalLen: int
4949
windowPos, hash: uint16
50-
head = newSeq[uint16](hashSize) # hash -> pos
50+
head = newSeq[uint16](hashSize) # hash -> pos
5151
chain = newSeq[uint16](windowSize) # pos a -> pos b
5252

5353
template updateHash(value: uint8) =
@@ -82,12 +82,11 @@ proc lz77Encode2(src: seq[uint8]): seq[uint16] =
8282
break
8383
inc chainLen
8484

85-
let offset = (
86-
if hashPos <= windowPos:
87-
windowPos - hashPos
88-
else:
89-
windowPos - hashPos + windowSize
90-
).int
85+
var offset: int
86+
if hashPos <= windowPos:
87+
offset = (windowPos - hashPos).int
88+
else:
89+
offset = (windowPos - hashPos + windowSize).int
9190

9291
if offset <= 0 or offset < prevOffset:
9392
break
@@ -136,7 +135,7 @@ proc lz77Decode2(src: seq[uint8], encoded: seq[uint16]): seq[uint8] =
136135
var ip, op: int
137136
while ip < encoded.len:
138137
if op >= result.len:
139-
result.setLen(result.len * 2)
138+
result.setLen(result.len * 2)
140139

141140
if encoded[ip] == uint16.high:
142141
let

0 commit comments

Comments
 (0)