Multiple variables vs one variable speed performance?
#1

Hello. I have a question about best anticheat checks that are placed inside foreach loops. I need precise and correct answer for usage of variables, since I don't know is it better to use one variable created on top of timer of anticheat and then used for each player to check if they are cheating or not. So the variable's value will be changed ~300 times in loop and loop needs to be finished asap efficiently. I've seen that I've created a stock function where the new variable is being declared in that stock.

CODE:

Код:
stock Checksomething( playerid ) {
new x;
// using x here
}

public anticheat() {
    foreach ( new i : Player ) {
         Checksomething( i );

    }

}
and I've replaced it to:

Код:
public anticheat() {
    new x;
    foreach ( new i : Player ) {
          // CODE USING x VARIABLE THAT'S DECLARED IN THIS TIMER, NOT IN FUNCTION.
    }
}
Which code is more efficient and why?
Reply


Messages In This Thread
Multiple variables vs one variable speed performance? - by ElMaestro123 - 24.03.2018, 20:08
Re: Multiple variables vs one variable speed performance? - by v1k1nG - 24.03.2018, 20:11
Re: Multiple variables vs one variable speed performance? - by ElMaestro123 - 24.03.2018, 20:13
Re: Multiple variables vs one variable speed performance? - by v1k1nG - 24.03.2018, 20:33
Re: Multiple variables vs one variable speed performance? - by Grim_ - 25.03.2018, 02:35

Forum Jump:


Users browsing this thread: 1 Guest(s)