Skip to content

Commit

Permalink
Less pointer math
Browse files Browse the repository at this point in the history
  • Loading branch information
z------------- committed Nov 25, 2023
1 parent 8005072 commit 4ebd829
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/mmdb.nim
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,10 @@ template readByte(s: Stream): uint8 =
s.readUint8()

proc readNumber(s: Stream; size: int): uint64 =
discard s.readData((addr result) +@ (sizeof(result) - size), size)
let size = min(size, sizeof(result))
discard s.readData(addr result, size)
beToHost64(addr result, addr result)
result = result shr (8 * (sizeof(result) - size))

# data decode #

Expand Down

0 comments on commit 4ebd829

Please sign in to comment.