For example, I want to have a multi weapon system in which each weapon has various stat modifiers. I could set each of these variables every time I swap to a weapon and have one variable for each thing (I.e. damage, range, etc.), or have an array with two variables each (I.e. damage primary and damage secondary) and set them only once when picking up the weapon. I don’t think this specific example will have a lot of weight on performance either way but am curious about this as a general concept (I.e. more setting variables vs less setting but more variables total).
Always profile! Not only “when in doubt”.
The short answer is “it depends”. It depends on the scale, it depends on the time-frame, data continuity, hardware used, drivers, operating system.
This is a classic question of compute vs memory. You would think that lowering the compute complexity would increase the frame-rate at the expense of higher memory consumption…
Until you profile and realize that half of your frame is spent waiting for something and the rest is spent accessing memory.
Never assume optimizations - always profile. Contemporary processors and compilers will often surprise you.