Answer the question
In order to leave comments, you need to log in
When is code duplication better than a function call?
Now we are not talking about the speed of development and not about the risks of making a mistake. By efficiency I mean the optimal ratio of execution speed and size of the executable file. For example, instead of calling get / set methods in simple cases, it is more efficient to access the property - as far as I know, competent optimizers do such a substitution. Can you generalize from a theoretical point of view the rule of the situation in which it is more efficient to substitute the body of a function instead of calling it?
Correction to the condition: a function can be called in more than one place, recursion is not required.
Answer the question
In order to leave comments, you need to log in
If at the moment the function has not been defined in memory (was not required) and the use of the logic of the code of this function is planned strictly once , then it is more reasonable to use the function body itself right away.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question