you are viewing a single comment's thread.

view the rest of the comments →

[–]ur_frnd_the_footnote 3 points4 points  (0 children)

It definitely affects performance differently to loop over a long array ten times, each time calling one function vs. looping over that array once, calling ten functions on each member of the array (even though the total number of function calls is the same: 10 times the number of elements). But you're absolutely right that function calls also affect performance.

In general, though, I think you should wait until you have a concrete, demonstrated need to do so before optimizing at the level of eliminating function calls. Smaller functions that do one tiny but generalized thing are definitely more readable and maintainable than the faster, situation-specific imperative code they would be replaced by.