3 ms·
At the risk of bike-shedding... It's not exactly secret knowledge that having "if (!cond) return" at the start of a function can save you one level of indentat
by yongjik 6y ago
At the risk of bike-shedding...
It's not exactly secret knowledge that having "if (!cond) return" at the start of a function can save you one level of indentation from the rest of the function. Sometimes the saving can be significant (4 spaces per line, for a hundred lines). Especially if you have multiple such conditions. Especially^2 if you are an old fart like me who prefers to have all their code fit inside 80-column width. (I prefer being able to examine at least three source files side-by-side, thank you very much.)
That said, it's a rather trivial observation, and just like everything else, should be used with moderation. So I'm not sure what's the big deal...
(OK, now get off my lawwwwwwwn...)
- galgalesh 6y agoIt's often hard for experienced people to understand what is trivial and non-trivial for less experienced people. This is why writing documentation is so hard when you're completely submerged into a project.