Probably a little faster with a loop inside the function, since there is a (small) cost to each function call. However, this will not make much difference.
This is truly premature optimization, and the root of all evil .
You have to write it so that it is clear, then if it is too slow, find out where it is slow and optimize it.
source
share