Merge pull request #4947 from flyx/tablesincfix

Fixes #4946
This commit is contained in:
Andreas Rumpf 2016-10-24 23:49:56 +02:00 • committed by GitHub
commit 5da5a27fa0

View file

@ -949,6 +949,7 @@ proc inc*[A](t: var CountTable[A], key: A, val = 1) =
var index = rawGet(t, key) var index = rawGet(t, key)
if index >= 0: if index >= 0:
inc(t.data[index].val, val) inc(t.data[index].val, val)
if t.data[index].val == 0: dec(t.counter)
else: else:
if mustRehash(len(t.data), t.counter): enlarge(t) if mustRehash(len(t.data), t.counter): enlarge(t)
rawInsert(t, t.data, key, val) rawInsert(t, t.data, key, val)