As presented there is the small cost of calling the sub which is avoided in the second case. However if the test is non-trivial it may be better to localise that in the sub to improve maintainability and clarity of the code and wear the small runtime cost of calling the sub. Almost always you will waste far more time worrying about a few microseconds of overhead than will ever be a problem or repay the worry time.
You may find the replies to Calling a subroutine - which is most efficient? helpful. Bottom line: there's almost no difference so do whatever is easiest to understand and maintain.
In reply to Re: How to select the code on basis of memory usage and execution time.
by GrandFather
in thread How to select the code on basis of memory usage and execution time.
by Rapunzel
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |