Completing C code with D style
Stanislav Blinov
stanislav.blinov at gmail.com
Wed Nov 10 04:54:58 UTC 2021
On Tuesday, 9 November 2021 at 11:03:09 UTC, forkit wrote:
> They both produce exactly the same output.
But do vastly different things.
> But I tell ya.. the cognitive load .. well.. it increased
> dramatically ;-)
Of course it did. Cuz you overthunk it. Dramatically.
Your D version allocates memory, for no good reason. I mean, to
store results, but you already have storage for them, so kinda
pointless. Your C version, OTOH, stores results on stack (so
again, why did you allocate for them in D?..), but allocates some
"string builder" for... what, exactly?
The program is filter, or sort + partition. Requires 0
allocations in C or D.
More information about the Digitalmars-d-learn
mailing list