Skip to content

Commit

Permalink
string is not nil anymore (#15352)
Browse files Browse the repository at this point in the history
  • Loading branch information
ringabout authored Sep 18, 2020
1 parent cbd78ec commit c57023f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
5 changes: 1 addition & 4 deletions lib/pure/collections/critbits.nim
Original file line number Diff line number Diff line change
Expand Up @@ -281,10 +281,7 @@ proc `[]=`*[T](c: var CritBitTree[T], key: string, val: T) =
template get[T](c: CritBitTree[T], key: string): T =
let n = rawGet(c, key)
if n == nil:
when compiles($key):
raise newException(KeyError, "key not found: " & $key)
else:
raise newException(KeyError, "key not found")
raise newException(KeyError, "key not found: " & key)

n.val

Expand Down
6 changes: 2 additions & 4 deletions lib/pure/strtabs.nim
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,8 @@ template get(t: StringTableRef, key: string) =
var index = rawGet(t, key)
if index >= 0: result = t.data[index].val
else:
when compiles($key):
raise newException(KeyError, "key not found: " & $key)
else:
raise newException(KeyError, "key not found")
raise newException(KeyError, "key not found: " & key)


proc len*(t: StringTableRef): int {.rtlFunc, extern: "nst$1".} =
## Returns the number of keys in `t`.
Expand Down

0 comments on commit c57023f

Please sign in to comment.