diff options
author | JamesP <jlp765@gmail.com> | 2015-10-05 15:16:43 +1000 |
---|---|---|
committer | JamesP <jlp765@gmail.com> | 2015-10-05 15:16:43 +1000 |
commit | 87a6268d3c93fef26ca5f7a74a3ec78b6aae667a (patch) | |
tree | 3e1bf9fe6082c263baef37d5479f5dc5ce509f83 | |
parent | 6587f63672dacb732b879d517132bec8a4f862e4 (diff) | |
download | Nim-87a6268d3c93fef26ca5f7a74a3ec78b6aae667a.tar.gz |
bug fix #3416 add wrapper around `[]=` to account for
changes in StringTableRef disabling inc of counter
-rw-r--r-- | lib/pure/strtabs.nim | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/pure/strtabs.nim b/lib/pure/strtabs.nim index 86f81aa43..0a1cc6167 100644 --- a/lib/pure/strtabs.nim +++ b/lib/pure/strtabs.nim @@ -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 |