summary refs log tree commit diff stats
path: root/lib/pure
diff options
context:
space:
mode:
authorDominik Picheta <dominikpicheta@googlemail.com>2015-05-05 14:14:22 +0100
committerDominik Picheta <dominikpicheta@googlemail.com>2015-05-05 14:14:22 +0100
commitac1fbf14696aa896286fce7cec485770789eedab (patch)
tree5344305b2ab58b211dd41f2cf0e401015ee3f56d /lib/pure
parent0be654efe11311fcf1200c0e7dba9ecd55fa5591 (diff)
parentb9e02b1efc14a309e613ec4d4cf8c793503bc797 (diff)
downloadNim-ac1fbf14696aa896286fce7cec485770789eedab.tar.gz
Merge branch 'devel'
Diffstat (limited to 'lib/pure')
-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.