Question 1: Is it faster to execute a function with alot of code to perform a task, or have a series of functions with less code to preform the same task collectivly.
My understanding of how Lua works would tell me having a single function would be better because lua wouldn't need to pass variables and create new function stacks. However, maybe a single large function may have a very large stack because of all the local variables and maybe having many small functions inside it would lessen the stack and run faster? Maybe both methods are basically the same?
Question 2: Is it faster to store string concatinations in locals if they are used multiple times, or is it faster to just reconcat them each time.
Code: Select all
function yo(var) print("sup"..var); print("sup"..var); print("sup"..var); print("sup"..var); end function yo(var) local str = "sup"..var; print(str); print(str); print(str); print(str); end