[bug] SlotFX.setBypassed no worky
-
@Orvillain said in [bug] SlotFX.setBypassed no worky:
What is the benefit of using const, in my situation?
I think the best answer is from Christoph
it yields a huge performance boost (because it can resolve the function call on compile time).
There is absolutely no reason to not declare UI widgets, references to modules (via Synth.getModulator() etc.) not as constregis good for accessing script level variables in midi callbacks and anywhere else where you would have had to use a script level var. But the moreregyou have (and you only get 32 per namespace) the worse the performance gets. Internallyregis like a predefined array that HISE is keeping track of. So the more values you add the more data it needs to go through each time to you access it.Another addition to Javascript: Use reg instead of var when declaring temporary variables which are accessed in the MIDI (or audio) callbacks. It tells the interpreter to store this in a fixed size container with faster access times:
If you have a script with lots of variables, the interpreter must search the entire array for every variable access (so the 23 - 40 ms are depending on how many other variables are defined in the script while the access time to reg slots stay the same).It's also possible since you're storing them in an object rather than as direct references that
constgives no performance benefit. But it's still good practice to use aconsthere. It makes it clear to other developers who might see your code (or your future self) that this variable is not meant to be reassigned, and it also prevents it being reassigned accidentality.