Setting array length without initializing/reallocating.
Jonathan Levi
catanscout at gmail.com
Sat Dec 12 00:53:09 UTC 2020
Wow, there went several hours of debugging.
Increasing the length of a slice, by setting its length, will
initialize the new elements and reallocate if necessary.
I did not realize length was "smart", I guess I should have
guessed.
Anyway, to work around this, and probably also be more clear,
create a new slice from the same pointer.
`array = array.ptr[0..newLength];`
More information about the Digitalmars-d
mailing list