Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize storing into uninit locations for arrays and seqs. #24619

Merged
merged 4 commits into from
Jan 19, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions lib/system.nim
Original file line number Diff line number Diff line change
Expand Up @@ -2965,14 +2965,12 @@ when notJSnotNims and not defined(nimSeqsV2):
assert y == "abcgh"
discard

proc arrayWith*[T](y: T, size: static int): array[size, T] {.raises: [].} =
proc arrayWith*[T](y: T, size: static int): array[size, T] {.noinit, raises: [].} =
## Creates a new array filled with `y`.
result = zeroDefault(array[size, T])
for i in 0..size-1:
result[i] = y

proc arrayWithDefault*[T](size: static int): array[size, T] {.raises: [].} =
proc arrayWithDefault*[T](size: static int): array[size, T] {.noinit, raises: [].} =
## Creates a new array filled with `default(T)`.
result = zeroDefault(array[size, T])
for i in 0..size-1:
result[i] = default(T)
Loading