in reply to How to select the code on basis of memory usage and execution time.
In both cases however, the difference will be unnoticeable for all practical purposes unless you call the subroutine over-and-over again.
Personally I would say, go with what feels most natural for yourself. If the whole of the subroutine depends on this flag, I would leave the test outside of the subroutine as that indicates more clearly --IMHO-- that the running of the subroutine depends on the value of the flag
CountZero
A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James
|
|---|