Completing C code with D style

Stanislav Blinov stanislav.blinov at gmail.com
Wed Nov 10 07:16:45 UTC 2021


On Wednesday, 10 November 2021 at 06:47:32 UTC, forkit wrote:

> btw. My pc has 24GB of main memory, and my CPU 8MB L3 cache. So 
> I really don't give a damn about allocations .. not one little 
> bit ;-)

That's not the point. The point is the program is doing 
unnecessary non-trivial work while introducing additional failure 
paths. It certainly has ways to go to reach Ali's AA solution, 
but still...

To put things in perspective, the algorithm can easily complete 
before malloc even returns (heck, before it even starts 
executing). There's what, 11 cmovs at most? It would take several 
dozen instructions, a couple of loops and a few other branches 
just to find malloc when you first call it. Not to mention it 
itself making that syscall and setting up its bins...

And I'm not even talking about optimization. Just, uh, 
non-pessimization.


More information about the Digitalmars-d-learn mailing list