3 ms·
> just discard the previous one, create a new one however you want I want to create it by re-using the memory of the previous one that I've just discarded, ple
by Joker_vD 3y ago
> just discard the previous one, create a new one however you want
I want to create it by re-using the memory of the previous one that I've just discarded, please (well, the one that will end up discarded, actually: it has to live until the map ends executing, hasn't it). Unfortunately, most of the languages' implementations/runtimes don't employ the Perceus algorithm.
- fifilura 3y agoCan you describe why you need it? Is it because of real performance concerns or just because it feels better knowing that you don't waste memory space and CPU cycles? If you really need it, you can always fall back to using mutables for this special list, and use immutables for the rest? This is probably the reason why languages don't implement the Perceus algorithm. If you really needed it you might as well do it by hand.
- duped 3y agoIn a managed language that's the job of the compiler. You don't need a fancy reference counter either, peephole optimizations will do.