Skip to content

Commit

Permalink
openArray[byte] hash is more reliably faster.
Browse files Browse the repository at this point in the history
  • Loading branch information
c-blake committed Jun 18, 2024
1 parent 18db2c0 commit c7ef1fe
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion tests/wf.nim
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ proc len(w: Word): uint32 = uint32(w) and wm
proc mem(w: Word): pointer = mf.mem +! int(w.uint32 shr wb)

# Case insens hash/==|Local stack allocator | may be faster than MAP_PRIVATE.
proc hash(w: Word): Hash {.inline.} = hashData(w.mem, w.len.int)
proc hash(w: Word): Hash {.inline.} =
hash toOpenArray[byte](cast[ptr UncheckedArray[byte]](w.mem), 0, w.len.int-1)

proc `==`(a, b: Word): bool {.inline.} =
a.len == b.len and cmemcmp(a.mem, b.mem, a.len) == 0
Expand Down

0 comments on commit c7ef1fe

Please sign in to comment.