From c7ef1fe4d034ae749edeea8391614050a0a8b512 Mon Sep 17 00:00:00 2001 From: Charles Blake Date: Tue, 18 Jun 2024 05:03:57 -0400 Subject: [PATCH] `openArray[byte]` hash is more reliably faster. --- tests/wf.nim | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/wf.nim b/tests/wf.nim index 22a5433..d924d76 100644 --- a/tests/wf.nim +++ b/tests/wf.nim @@ -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