mirror of
https://github.com/nim-lang/Nim.git
synced 2026-05-25 06:18:16 +00:00
fixes #25718 This pull request optimizes sequence allocation in the Nim standard library by introducing a way to create uninitialized sequence payloads for element types that don't require zero-initialization. The changes allow for more efficient memory allocation when initializing sequences with types that have no references, avoiding unnecessary zeroing of memory. Sequence allocation and initialization improvements: * Added the `newSeqUninitRaw` procedure to create sequence payloads with a specified length without forcing zero-initialization for element types marked as `ntfNoRefs`. (`lib/system/sysstr.nim`, [lib/system/sysstr.nimR277-R292](diffhunk://#diff-bcaa1967f436ad03877f353823c08a8b4a719fe387629d33aab4bddf16534b5eR277-R292)) * Modified the `extendCapacityRaw` procedure and the `setLengthSeqImpl` template to use `newSeqUninitRaw` when zero-initialization is not required, controlled by the `doInit` static parameter. (`lib/system/sysstr.nim`, [[1]](diffhunk://#diff-bcaa1967f436ad03877f353823c08a8b4a719fe387629d33aab4bddf16534b5eR277-R292) [[2]](diffhunk://#diff-bcaa1967f436ad03877f353823c08a8b4a719fe387629d33aab4bddf16534b5eL316-R335)