From 7d3a6b42d9deb8eef0ee0f50ba3bee2476502a4f Mon Sep 17 00:00:00 2001 From: Araq Date: Sat, 2 May 2015 07:59:13 +0200 Subject: fixes #2625 --- lib/pure/collections/tables.nim | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'lib/pure') diff --git a/lib/pure/collections/tables.nim b/lib/pure/collections/tables.nim index 232e52c89..a9357ce67 100644 --- a/lib/pure/collections/tables.nim +++ b/lib/pure/collections/tables.nim @@ -819,15 +819,18 @@ proc enlarge[A](t: var CountTable[A]) = swap(t.data, n) proc `[]=`*[A](t: var CountTable[A], key: A, val: int) = - ## puts a (key, value)-pair into `t`. `val` has to be positive. + ## puts a (key, value)-pair into `t`. assert val > 0 var h = rawGet(t, key) if h >= 0: t.data[h].val = val else: - h = -1 - h - t.data[h].key = key - t.data[h].val = val + if mustRehash(len(t.data), t.counter): enlarge(t) + rawInsert(t, t.data, key, val) + inc(t.counter) + #h = -1 - h + #t.data[h].key = key + #t.data[h].val = val proc initCountTable*[A](initialSize=64): CountTable[A] = ## creates a new count table that is empty. -- cgit 1.4.1-2-gfad0