484
got him
(lemy.lol)
Post funny things about programming here! (Or just rant about your favourite programming language.)
Not sure why you had to do the inverted predicate check again in your first example. You already have the information encoded in the value of retval. It can be written like this:
With a return value you have to add 4 extra lines. This overhead remains constant as you add more checks and more business logic.
Yes all the other suggestions are better than early returns in business logic and would help with leaks. Would be nice if we had RAII outside of C++. I think Rust has it? Haven't done Rust yet.