alloca is slow and dangerous

IGotD- nise at nise.com
Sun Jan 3 19:33:10 UTC 2021


On Sunday, 3 January 2021 at 19:12:47 UTC, welkam wrote:
>
> Usually this forum has excellent technical responses but this 
> time you dropped ball on this one. Behold
>
> byte[128] = void;
>

I think the default initialization in D is an excellent feature. 
MS has already stated that they want to do this in C++. Sure your 
example circumvents that but still the default initialization 
help. My point was that more that you will allocate exactly the 
elements you need on the stack. For example you have have a 
maximum of 1024 elements but usually you only use one or two 
elements. Then static allocation of 1024 elements become crazy 
big and also it generate more cache misses.

I'm not sure why the stack allocation needs to be so enormously 
complicated like the seminar. In general you just need to 
subtract the stack pointer.




More information about the Digitalmars-d mailing list