help Nim optimize intsets.initIntSet

This commit is contained in:
Andreas Rumpf 2018-12-30 11:45:07 +01:00
commit 2ee2022c29

View file

@ -217,14 +217,13 @@ proc initIntSet*: IntSet =
# newSeq(result.data, InitIntSetSize) # newSeq(result.data, InitIntSetSize)
# result.max = InitIntSetSize-1 # result.max = InitIntSetSize-1
when defined(nimNoNilSeqs): result = IntSet(
result.data = @[] elems: 0,
else: counter: 0,
result.data = nil max: 0,
result.max = 0 head: nil,
result.counter = 0 data: when defined(nimNoNilSeqs): @[] else: nil)
result.head = nil # a: array[0..33, int] # profiling shows that 34 elements are enough
result.elems = 0
proc clear*(result: var IntSet) = proc clear*(result: var IntSet) =
## Clears the IntSet back to an empty state. ## Clears the IntSet back to an empty state.