5 ms·
> A single while loop could do the job correctly and use less RAM. It'd probably also be faster. But that wouldn't be a rusty thing to do? No, the "single whil
by shiomiru 16d ago
> A single while loop could do the job correctly and use less RAM. It'd
probably also be faster. But that wouldn't be a rusty thing to do?
No, the "single while loop" is just harder to implement than a naive
recursion, because recursion is a natural way to implement tree traversal.
With a while loop, you need an explicit stack, which is more complex.
(A stackless traversal seems unrealistic here, as getting the succeeding
node would be too expensive. Not that I've tried...)
> I look at code from the heirloom project and, despite its warts, I think
we've lost something in the past 45 years or so.
I've just tried and heirloom rm segfaults on the same test too. Which is
no wonder, seeing how that code also recurses.
(It's mentioned somewhere else in the thread, but this is exactly the
reason why GNU had to specify "no hard limits" as a policy. Unix used to
be full of such bugs.)
- tosti 15d agoThank you for clearing that up. Good points!