diff options
author | ringabout <43030857+ringabout@users.noreply.github.com> | 2023-11-01 14:54:47 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-01 07:54:47 +0100 |
commit | 92141e82ede93028be5781d6f4e906cefa3b03eb (patch) | |
tree | ab3034f14e197b20f1439f8ec26829cac28e4c24 /lib/pure/collections/sets.nim | |
parent | 801c02bf48b1612c8bf58ed113f944c9d6e32ead (diff) | |
download | Nim-92141e82ede93028be5781d6f4e906cefa3b03eb.tar.gz |
fixes #22883; replace `default(typeof(` with `reset`; suppress `Unsaf… (#22895)
fixes #22883 …eDefault` warnings avoid issues mentioned by https://forum.nim-lang.org namely, it allocated unnecessary stack objects in the loop ```c while (1) { tyObject_N__8DSNqSGSHBKOhI8CqSgAow T5_; nimZeroMem((void *)(&T5_), sizeof(tyObject_N__8DSNqSGSHBKOhI8CqSgAow)); eqsink___test4954_u450((&(*t_p0).data.p->data[i].Field1), T5_); } ``` It might be more efficient in some cases follow up https://github.com/nim-lang/Nim/pull/21821
Diffstat (limited to 'lib/pure/collections/sets.nim')
-rw-r--r-- | lib/pure/collections/sets.nim | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/pure/collections/sets.nim b/lib/pure/collections/sets.nim index 220ef3bb6..99bb299d5 100644 --- a/lib/pure/collections/sets.nim +++ b/lib/pure/collections/sets.nim @@ -382,7 +382,7 @@ proc clear*[A](s: var HashSet[A]) = s.counter = 0 for i in 0 ..< s.data.len: s.data[i].hcode = 0 - s.data[i].key = default(typeof(s.data[i].key)) + reset(s.data[i].key) proc union*[A](s1, s2: HashSet[A]): HashSet[A] = @@ -816,7 +816,7 @@ proc clear*[A](s: var OrderedSet[A]) = for i in 0 ..< s.data.len: s.data[i].hcode = 0 s.data[i].next = 0 - s.data[i].key = default(typeof(s.data[i].key)) + reset(s.data[i].key) proc len*[A](s: OrderedSet[A]): int {.inline.} = ## Returns the number of elements in `s`. |