SA-MP Forums Archive
What kind of variables are better? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: What kind of variables are better? (/showthread.php?tid=441813)



What kind of variables are better? - [DOG]irinel1996 - 04.06.2013

Hello, I got confused with something, maybe this is a stupid question but which script of the following ones is better? I'm talking about the memory used due the variables.

pawn Код:
stock FunctionA() {
    new string[128];
    format(string, 128, ...........................);
}

stock FunctionB() {
    new string[128];
    format(string, 128, ...........................);
}

stock FunctionC() {
    new string[128];
    format(string, 128, ...........................);
}

//As you see, I declared 3 variables with 128 cells.
Ok, that's one, what about next one:
pawn Код:
new string[128];

stock FunctionA() {
    format(string, 128, ...........................);
}

stock FunctionB() {
    format(string, 128, ...........................);
}

stock FunctionC() {
    format(string, 128, ...........................);
}

//Just one variable declared.
So, as you saw in the first one I declared 3 variables, and in the second one just one variable. My question is which one is better and why?

Thank you for helping, also, if you give me some reasons about why one of them is better I'll be grateful.

Thank you all!


Re: What kind of variables are better? - [DOG]irinel1996 - 04.06.2013

Thank you ******, always helping, solved.

PD: also, thank you for the suggestions.


Re: What kind of variables are better? - Universal - 04.06.2013

Quote:
Originally Posted by ******
Посмотреть сообщение
6) Generally you shouldn't use "stock" (irrelevant to the question, but important anyway).
May I know why?


Re: What kind of variables are better? - [DOG]irinel1996 - 07.06.2013

Thank you for bringing us all this information ******.

Regards.