Skip to content

Commit 6acb7c8

Browse files
committed
fixup
1 parent e0918b3 commit 6acb7c8

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

lib/pure/hashes.nim

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ proc hashUInt64*(x: uint64): Hash {.inline.} =
9898
doAssert false
9999
else:
100100
# would orders of magnitude worse, see thashes_perf toHighOrderBits
101-
# faster than using murmurhash or Jenkins via
102101
# hashData(cast[pointer](unsafeAddr x), type(x).sizeof)
103102

104103
# would a bit worse, see thashes_perf toInt64
@@ -118,14 +117,12 @@ proc hashUInt64*(x: uint64): Hash {.inline.} =
118117

119118
proc hashUInt32*(x: uint32): Hash {.inline.} =
120119
## for internal use; user code should prefer `hash` overloads
121-
# calling `hashUInt64(x)` would perform 1.736 worse, see thashes_perf toInt32
120+
# calling `hashUInt64(x)` would perform 1.7X slower, see thashes_perf toInt32
122121
when nimvm: # in vmops
123122
doAssert false
124123
else:
125124
# inspired from https://gist.github.com/badboy/6267743
126125
var x = x xor ((x shr 20) xor (x shr 12))
127-
# debugEcho ("hashUInt32", x)
128-
# return cast[Hash](x xor (x shr 7) xor (x shr 4))
129126
result = cast[Hash](x xor (x shr 7) xor (x shr 4))
130127

131128
proc hash*[T: SomeNumber | Ordinal | char](x: T): Hash {.inline.} =

tests/collections/ttables.nim

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -164,11 +164,10 @@ block tableconstr:
164164

165165
block ttables2:
166166
proc TestHashIntInt() =
167-
var tab = initTable[int, int]()
168-
const n = 1_000_000 # bottleneck: 50 seconds on OSX in debug mode
169-
for i in 1..n:
167+
var tab = initTable[int,int]()
168+
for i in 1..1_000_000:
170169
tab[i] = i
171-
for i in 1..n:
170+
for i in 1..1_000_000:
172171
var x = tab[i]
173172
if x != i : echo "not found ", i
174173

@@ -185,6 +184,7 @@ block ttables2:
185184
delTab.del(i)
186185
delTab[5] = 5
187186

187+
188188
run1()
189189
echo "2"
190190

@@ -340,7 +340,8 @@ block tablesref:
340340
block anonZipTest:
341341
let keys = @['a','b','c']
342342
let values = @[1, 2, 3]
343-
doAssert "{'a': 1, 'b': 2, 'c': 3}" == $ toTable zip(keys, values)
343+
var t = toTable(zip(keys, values))
344+
doAssert toSeq(t.pairs).sorted == @[('a', 1), ('b', 2), ('c', 3)]
344345

345346
block clearTableTest:
346347
var t = newTable[string, float]()

0 commit comments

Comments
 (0)