summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKonstantin Molchanov <moigagoo@live.com>2017-12-27 13:30:32 +0400
committerKonstantin Molchanov <moigagoo@live.com>2017-12-27 13:30:32 +0400
commitc36d7ffc7c771fcece05bf882fee02fae4261edf (patch)
tree407832b81e7289149cfb8b728643633be16bb7ed
parent53cf0b2c24e5adc4fa99e49ddf1834991d663846 (diff)
downloadNim-c36d7ffc7c771fcece05bf882fee02fae4261edf.tar.gz
Tables: make `toCountTable` actually count the elements of the input openArray.
-rw-r--r--lib/pure/collections/tables.nim2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/pure/collections/tables.nim b/lib/pure/collections/tables.nim
index 01767956e..d8c133bce 100644
--- a/lib/pure/collections/tables.nim
+++ b/lib/pure/collections/tables.nim
@@ -968,7 +968,7 @@ proc initCountTable*[A](initialSize=64): CountTable[A] =
 proc toCountTable*[A](keys: openArray[A]): CountTable[A] =
   ## creates a new count table with every key in `keys` having a count of 1.
   result = initCountTable[A](rightSize(keys.len))
-  for key in items(keys): result[key] = 1
+  for key in items(keys): result.inc key
 
 proc `$`*[A](t: CountTable[A]): string =
   ## The `$` operator for count tables.