help Nim optimize intsets.initIntSet
This commit is contained in:
parent
82c009a2cb
commit
2ee2022c29
1 changed files with 7 additions and 8 deletions
|
|
@ -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.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue