summary refs log tree commit diff stats
path: root/lib/pure/collections/tables.nim
diff options
context:
space:
mode:
authorAndreas Rumpf <ar@kimeta.de>2014-04-13 00:20:25 +0200
committerAndreas Rumpf <ar@kimeta.de>2014-04-13 00:20:25 +0200
commit587f0bd0863b381f5d0045fefedac92e3c504bde (patch)
treed4c3790ce72d9ff5a6127685b705164c8331bbd6 /lib/pure/collections/tables.nim
parent6b1543a6a8514014c05cd164549d9f30d341a6ed (diff)
downloadNim-587f0bd0863b381f5d0045fefedac92e3c504bde.tar.gz
fixes '==' for TTTable
Diffstat (limited to 'lib/pure/collections/tables.nim')
-rw-r--r--lib/pure/collections/tables.nim8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/pure/collections/tables.nim b/lib/pure/collections/tables.nim
index 40ae57b5a..112f41c66 100644
--- a/lib/pure/collections/tables.nim
+++ b/lib/pure/collections/tables.nim
@@ -191,7 +191,13 @@ proc `$`*[A, B](t: TTable[A, B]): string =
   dollarImpl()
   
 proc `==`*[A, B](s, t: TTable[A, B]): bool =
-  s.counter == t.counter and s.data == t.data
+  if s.counter == t.counter:
+    # different insertion orders mean different 'data' seqs, so we have
+    # to use the slow route here:
+    for key, val in a:
+      if not hasKey(t, key): return false
+      if mget(t, key) != val: return false
+    return true
   
 proc indexBy*[A, B, C](collection: A, index: proc(x: B): C): TTable[C, B] =
   ## Index the collection with the proc provided.