Setting array length without initializing/reallocating.
Dukc
ajieskola at gmail.com
Sun Dec 13 21:01:18 UTC 2020
On Sunday, 13 December 2020 at 20:03:46 UTC, Jackson22 wrote:
>> No bounds checking. That slice can extend into memory that
>> isn't of that type or even allocated to the process.
>
> No *automatic* bounds checking != no bounds checking.
>
> There's a reason .ptr exist, I wish people would stop
> pretending that using it where it is appropriate is somehow
> going to lead to failure when there are more successful
> programming languages that have zero automatic bounds checking.
Yes it's possible to without automatic bounds checks. Sometimes
one has to -when using those older langages or doing very
low-level system programming. And other times it may not be
necessary, but still worth it to gain that last bit of
performance when optimizing. These are the reasons why `.ptr`
exists.
We really don't know whether either of those cases apply to OP:s
case, but if the length extension with implicit duplications were
even close to the desired performance, it seems unlikely.
>
> Why did you quote expensive? Are you implying it isn't
> expensive? Are you saying re-allocating 4 GB of memory every 6
> ms isn't expensive?
I think he was comparing to extending the array in-place, but in
a bounds-checked way.
More information about the Digitalmars-d
mailing list