Skip to content

Commit

Permalink
All warnings are also false positives, but deserved careful inspection
Browse files Browse the repository at this point in the history
as per f7b2a5d `ref object` commentary.
E.g., inf.loop for `tern.rawInsert` must return something `new`'d at
some point while `trie.rawInsert` ensures non-nil returns another way.
  • Loading branch information
c-blake committed Dec 24, 2024
1 parent f7b2a5d commit 690381f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
7 changes: 3 additions & 4 deletions cligen/tern.nim
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,17 @@
##``CritBitTree`` (except a ``longestMatch`` -> ``longest`` parameter rename
##which will be trapped by the compiler if you use kwargs). ``CritBitTree``
##itself is API-compatible with the union of both ``HashSet`` and ``Table``.
#{.warning[Uninit]:off, warning[ProveInit]:off.} # Should be verbosity:2 not 1
{.warning[Uninit]:off, warning[ProveInit]:off.} # Should be verbosity:2 not 1
import std/algorithm, ./sysUt # reverse, postInc

const NUL* = '\0'
type
NodeOb*[T] {.acyclic.} = object
Node[T] {.acyclic.} = ref object
ch*: char
cnt*: int
when T isnot void:
val*: T
kid*: array[3, ref NodeOb[T]] #0,1,2 ~ <,=,>
Node*[T] = ref NodeOb[T]
kid*: array[3, Node[T]] #0,1,2 ~ <,=,>
Tern*[T] = object ## A Tern can be used as either a mapping from strings
## to type ``T`` or as a set(strings) if ``T`` is void.
root*: Node[T]
Expand Down
7 changes: 3 additions & 4 deletions cligen/trie.nim
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,16 @@
##digital search tree family. It is drop-in compatible-ish with ``CritBitTree``
##itself compatible with both ``HashSet[string]`` & ``Table[string,*]``. It was
##easier for me to extend this with ``match``&``nearLev`` than ``CritBitTree``.
#{.warning[Uninit]:off, warning[ProveInit]:off.} # Should be verbosity:2 not 1
{.warning[Uninit]:off, warning[ProveInit]:off.} # Should be verbosity:2 not 1
import ./sysUt, std/[sets, algorithm, strutils] # findUO|findO, HashSet, reverse
type
NodeOb[T] {.acyclic.} = object
Node[T] {.acyclic.} = ref object
term*: bool
cnt*: uint32
when T isnot void:
val*: T
kidc*: string
kidp*: seq[ref NodeOb[T]]
Node*[T] = ref NodeOb[T]
kidp*: seq[Node[T]]
Trie*[T] = object
root*: Node[T]
depth*: int # Depth of Tree
Expand Down

0 comments on commit 690381f

Please sign in to comment.