Skip to content

Commit

Permalink
_
Browse files Browse the repository at this point in the history
  • Loading branch information
timotheecour committed Feb 18, 2020
1 parent 2e7b98d commit bc86a80
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/pure/collections/intsets.nim
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,15 @@ type
a: array[0..33, int] # profiling shows that 34 elements are enough

proc mustRehash(length, counter: int): bool {.inline.} =
# FACTOR with hashcommon.mustRehash
assert(length > counter)
result = (length * 2 < counter * 3) or (length - counter < 4)

# FACTOR
proc nextTry(h, maxHash: Hash, perturb: var Hash): Hash {.inline.} =
# FACTOR with hashcommon.nextTry
const PERTURB_SHIFT = 5
perturb = perturb shr PERTURB_SHIFT
var perturb2 = cast[uint](perturb) shr PERTURB_SHIFT
perturb = cast[Hash](perturb2)
result = ((5*h) + 1 + perturb) and maxHash

proc intSetGet(t: IntSet, key: int): PTrunk =
Expand Down

0 comments on commit bc86a80

Please sign in to comment.