In recursive scenarios, what brings more performance? Doing 3-4 simple calculations once, store result on a variable and then use variable maximum 3-4 times in each recursive function call? Or to skip saving result on a variable and just do the 3-4 math operations each of the 3-4 times needed? What bugs me with variable is that since the function is recursive, each 4-byte variable will be stored in stack until the function returns and that may add up a lot. I don't know how much big of a deal it is to allocate memory for an integer and store a value in there, but it does sound like it is something. i.e. Scenario 1: int a = w + x - y / z; use a; use a; use a; use a; vs Scenario 2: use w + x - y / z; use w + x - y / z; use w + x - y / z; use w + x - y / z;
Thanks in advance.