Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Reduces the complexity of a statement in `rawGet`.
It appears that that statement causes issues when run with `-mm:orc`, as `hasKey` invokes this proc and this can lead to the error `Exception message: field 'key' is not accessible for type 'NodeObj' using 'isLeaf = 255'.

Applying this change has shown that the error no longer occurs.
  • Loading branch information
PhilippMDoerner authored Sep 20, 2022
1 parent 4a1bda6 commit a9f8aab
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/pure/collections/critbits.nim
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,19 @@ func len*[T](c: CritBitTree[T]): int {.inline.} =

result = c.count

proc rawGet[T](c: CritBitTree[T], key: string): Node[T] =
proc rawGet[T](c: CritBitTree[T], key: string): Node[T]=
var it = c.root
while it != nil:
if not it.isLeaf:
let ch = if it.byte < key.len: key[it.byte] else: '\0'
let dir = (1 + (ch.ord or it.otherBits.ord)) shr 8
it = it.child[dir]
else:
return if it.key == key: it else: nil
let itKey = it.key
if itKey == key:
return it
else:
nil

func contains*[T](c: CritBitTree[T], key: string): bool {.inline.} =
## Returns true if `c` contains the given `key`.
Expand Down

0 comments on commit a9f8aab

Please sign in to comment.