Re: The obvious thing I should've learned 5 years ago
Posted: Sun Mar 14, 2010 1:19 pm
It wasn't Linus; it was the guy who wrote the kernel coding style file (linux-XX.XX[.XX[-ABC]]/Documentation/CodingStyle). Here's an online version: http://lxr.linux.no/#linux+v2.6.33/Docu ... odingStyleearlz wrote:Yup, I believe Linus or some famous coder put it something like "Using break and continue is bad cause it's basically a disguised goto. But if you have over 3 levels of indentation, your screwed anyway"JamesM wrote:Personally I use "early-exit" operators as much as possible in order to reduce the amount of nesting needed and therefore make code easier to read. That means break, continue, return.
They don't impact performance and it's blatantly obvious what the intention is. If it improves my code's readability, it's worth it. YMMV.