summary refs log tree commit diff stats
path: root/lib/pure/collections
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2018-12-30 11:45:07 +0100
committerAndreas Rumpf <rumpf_a@web.de>2018-12-30 11:45:16 +0100
commit2ee2022c29ec4774eda51cb431052a9fc24982a7 (patch)
tree6dc505bb90701f3c630c2c75353b8971dafe1dc1 /lib/pure/collections
parent82c009a2cbc5d07ab9a847f1c58228a20efaf219 (diff)
downloadNim-2ee2022c29ec4774eda51cb431052a9fc24982a7.tar.gz
help Nim optimize intsets.initIntSet
Diffstat (limited to 'lib/pure/collections')
-rw-r--r--lib/pure/collections/intsets.nim15
1 files changed, 7 insertions, 8 deletions
diff --git a/lib/pure/collections/intsets.nim b/lib/pure/collections/intsets.nim
index 8034e4c0a..f6d3a3d11 100644
--- a/lib/pure/collections/intsets.nim
+++ b/lib/pure/collections/intsets.nim
@@ -217,14 +217,13 @@ proc initIntSet*: IntSet =
 
   # newSeq(result.data, InitIntSetSize)
   # result.max = InitIntSetSize-1
-  when defined(nimNoNilSeqs):
-    result.data = @[]
-  else:
-    result.data = nil
-  result.max = 0
-  result.counter = 0
-  result.head = nil
-  result.elems = 0
+  result = IntSet(
+    elems: 0,
+    counter: 0,
+    max: 0,
+    head: nil,
+    data: when defined(nimNoNilSeqs): @[] else: nil)
+  #  a: array[0..33, int] # profiling shows that 34 elements are enough
 
 proc clear*(result: var IntSet) =
   ## Clears the IntSet back to an empty state.