summary refs log tree commit diff stats
path: root/lib/pure/collections
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2011-05-07 22:13:24 +0200
committerAraq <rumpf_a@web.de>2011-05-07 22:13:24 +0200
commit73c355176653e5b643f2bbbdc4f967cc24b3ee3b (patch)
tree8b25ccdebec59fbd7773f273b66b4fe1cf8e0643 /lib/pure/collections
parent7d2b3dd6db07203d7ff7a083ddae62aa8e7942c8 (diff)
downloadNim-73c355176653e5b643f2bbbdc4f967cc24b3ee3b.tar.gz
gc tweaking to gain a few percent of performance
Diffstat (limited to 'lib/pure/collections')
-rw-r--r--lib/pure/collections/hashtables.nim9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/pure/collections/hashtables.nim b/lib/pure/collections/hashtables.nim
index 29ba6bf6f..4f4c4f5a0 100644
--- a/lib/pure/collections/hashtables.nim
+++ b/lib/pure/collections/hashtables.nim
@@ -216,9 +216,16 @@ proc `[]=`*[A, B](t: TOrderedHashTable[A, B], key: A, val: B) =
     inc(t.counter)
 
 proc del*[A, B](t: TOrderedHashTable[A, B], key: A) =
-  ## deletes `key` from hash table `t`.
+  ## deletes `key` from hash table `t`. Warning: It's inefficient for ordered
+  ## tables: O(n).
   var index = RawGet(t, key)
   if index >= 0:
+    var i = t.first
+    while i >= 0:
+      var nxt = t.data[i].next
+      if nxt == index: XXX
+      i = nxt
+    
     t.data[index].slot = seDeleted
     dec(t.counter)