Skip to content

Commit

Permalink
Thanks to @demotomohiro for the suggestion
Browse files Browse the repository at this point in the history
  • Loading branch information
planetis-m committed Oct 7, 2024
1 parent 4cee44b commit 25080a2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/jsonpak/private/bitabs.nim
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type

proc slotsNeeded(count: Natural): int {.inline.} =
# Make sure to synchronize with `mustRehash`
result = nextPowerOfTwo(count * 3 div 2 + 4)
result = nextPowerOfTwo(count div 2 + count + 4)

proc initBiTable*[T](initialSize = defaultInitialSize): BiTable[T] =
BiTable[T](vals: @[], keys: newSeq[Key](slotsNeeded(initialSize)))
Expand All @@ -39,7 +39,7 @@ proc len*[T](t: BiTable[T]): int = t.vals.len

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

const
idStart = 1
Expand Down
2 changes: 1 addition & 1 deletion tests/tparser.nim
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ proc main =
for data in items(invalid):
try:
discard parseJson(data)
assert false, "Expected PathError"
assert false, "Expected JsonParsingError"
except JsonParsingError:
assert true

Expand Down

0 comments on commit 25080a2

Please sign in to comment.