Effects of very large functions in a C program?
Functions are an important part of organizing code in any programming language. Although the performance of having one large function would reduce the use of function calls and therefore reduce stack jumps and lead to more efficient code. But not every project has the luxury of not being modular and having code that is unreadable or worse than confusing or misleading. Over time, the cost of a project with large features will be much greater than a project with small features in terms of maintenance, refactoring, feature enhancements, etc. A function that is large is only important when analyzed in a specific context, and be in some situations where a large function cannot be broken down into smaller pieces and is entirely acceptable if well designed and simple.
Remember the first rule of writing functions do one thing and one thing well
.
source to share
In C programming, a stack frame is created for each function call, so in the case of a single function, there will only be one stack, and there is no need for a stack jump, but in the case of using many subdivided functions, each function will have a separate stack and for each function call there will be stack jump, so performance may be degraded depending on compiler optimizations.
source to share