08.06.2018, 18:21
Also huge switch case statements bring alot of compile-time:
This code in a blank script will lead to huge compile times already.
It\'s not only the length of the script that matters, it\'s also the way it\'s written.
Changing it to this does the exact same thing, but will make compile time alot faster again.
The huge switch statement made the compiler generate a separate if-statement for every value, so it was in fact creating 15000 if-statements.
Not to mention that would generate a massive AMX file as well.
Code:
switch (somevar) { case 0 .. 4999: { // Do something } case 5000 .. 9999: { // Do something } case 10000 .. 14999: { // Do something } }
It\'s not only the length of the script that matters, it\'s also the way it\'s written.
Code:
if (0 <= somevar <= 4999) // Do something if (5000 <= somevar <= 9999) // Do something if (10000 <= somevar <= 14999) // Do something
The huge switch statement made the compiler generate a separate if-statement for every value, so it was in fact creating 15000 if-statements.
Not to mention that would generate a massive AMX file as well.