3 ms·
It does looks simpler but unlocks several footguns: order of edge cases,edge cases deeply nested within other condition with different context, early return th
by countWSS 3y ago
It does looks simpler but unlocks several footguns:
order of edge cases,edge cases deeply
nested within other condition with different context,
early return that doesn't reset some mutex/setting/return condition.
Before blindly rewriting, have a mental picture of
what is context/state at the point of early return,
which at each time has to achieve the goals of function,
setting background states/data points/return pointers/etc.
Its easy only in simple functions.
- sirwhinesalot 3y agoAny good modern language has ways of ensuring that resources are properly released on early returns: RAII, using/with, defer, etc.