mirror of
https://github.com/nim-lang/Nim.git
synced 2026-02-17 16:38:33 +00:00
bug fix #3416 add wrapper around []= to account for
changes in StringTableRef disabling inc of counter
This commit is contained in:
@@ -135,15 +135,18 @@ proc enlarge(t: StringTableRef) =
|
||||
if not isNil(t.data[i].key): rawInsert(t, n, t.data[i].key, t.data[i].val)
|
||||
swap(t.data, n)
|
||||
|
||||
proc `[]=`*(t: StringTableRef, key, val: string) {.rtl, extern: "nstPut".} =
|
||||
## puts a (key, value)-pair into `t`.
|
||||
proc addVal(t: StringTableRef, key, val: string) =
|
||||
var index = rawGet(t, key)
|
||||
if index >= 0:
|
||||
t.data[index].val = val
|
||||
else:
|
||||
if mustRehash(len(t.data), t.counter): enlarge(t)
|
||||
rawInsert(t, t.data, key, val)
|
||||
inc(t.counter)
|
||||
|
||||
proc `[]=`*(t: StringTableRef, key, val: string) {.rtl, extern: "nstPut".} =
|
||||
## puts a (key, value)-pair into `t`.
|
||||
t.addVal(key, val)
|
||||
inc(t.counter)
|
||||
|
||||
proc raiseFormatException(s: string) =
|
||||
var e: ref ValueError
|
||||
|
||||
Reference in New Issue
Block a user