summary refs log tree commit diff stats
path: root/lib/pure/collections/tables.nim
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2015-05-02 07:59:13 +0200
committerAraq <rumpf_a@web.de>2015-05-03 01:08:48 +0200
commit7d3a6b42d9deb8eef0ee0f50ba3bee2476502a4f (patch)
tree7ca0a10db930795226ef440b900748f4383aa668 /lib/pure/collections/tables.nim
parentfe268b7df7f6b8f7dbfc7eba9c159c6bca769520 (diff)
downloadNim-7d3a6b42d9deb8eef0ee0f50ba3bee2476502a4f.tar.gz
fixes #2625
Diffstat (limited to 'lib/pure/collections/tables.nim')
-rw-r--r--lib/pure/collections/tables.nim11
1 files changed, 7 insertions, 4 deletions
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.