Skip to content

Commit

Permalink
Change prior make-like-std/tables.Table idea to just drop the 2nd
Browse files Browse the repository at this point in the history
overload and never raise.
  • Loading branch information
c-blake committed Dec 15, 2021
1 parent cc98f1f commit 14f4e39
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
9 changes: 4 additions & 5 deletions adix/ditab.nim
Original file line number Diff line number Diff line change
Expand Up @@ -371,11 +371,10 @@ proc getOrDefault*[K,V](t: DITab[K,V], key: K, default=default(V)): V{.inline.}=
let i = t.rawGet(key)
result = if i >= 0: t.data[i].val else: default

proc del*[K,V](t: var DITab[K,V], key: K, doRaise=false) {.inline.} =
if t.missingOrExcl(key) and doRaise: key.raiseNotFound

proc del*[K,V](t: var DITab[K,V], key: K, had: var bool) {.inline.} =
had = not t.missingOrExcl(key)
proc del*[K,V](t: var DITab[K,V], key: K) {.inline.} =
## delete one key `key` from `t`; If you want to know if it was present then
## use `missingOrExcl`, `take`, or `pop` instead.
discard t.missingOrExcl(key)

proc `==`*[K,V](x, y: DITab[K,V]): bool =
if isNil(x): return isNil(y) # 2 nil => true
Expand Down
10 changes: 4 additions & 6 deletions adix/lptabz.nim
Original file line number Diff line number Diff line change
Expand Up @@ -1041,12 +1041,10 @@ proc getOrDefault*[K,V,Z;z:static[int]](t: LPTabz[K,V,Z,z], key: K,
let i = t.rawGet(key)
result = if i >= 0: t.cell(i).val else: default

proc del*[K,V,Z;z:static[int]](t: var LPTabz[K,V,Z,z], key: K, doRaise=false) {.inline.} =
if t.missingOrExcl(key) and doRaise: key.raiseNotFound

proc del*[K,V,Z;z:static[int]](t: var LPTabz[K,V,Z,z], key: K,
had: var bool) {.inline.} =
had = not t.missingOrExcl(key)
proc del*[K,V,Z;z:static[int]](t: var LPTabz[K,V,Z,z], key: K) {.inline.} =
## delete one key `key` from `t`; If you want to know if it was present then
## use `missingOrExcl`, `take`, or `pop` instead.
discard t.missingOrExcl(key)

proc `==`*[K,V: not void,Z;z:static[int]](x, y: LPTabz[K,V,Z,z]): bool =
if x.len == 0: return y.len == 0 # 2 nil => true
Expand Down

0 comments on commit 14f4e39

Please sign in to comment.