Posts: 7,801
Threads: 187
Joined: Feb 2010
Reputation:
0
I have always been under the impression that local variables are better. I could be wrong, but I don't think I am!
Posts: 80
Threads: 22
Joined: Jan 2012
Reputation:
0
I believe that too, because global variables are active all the time, I mean server has to keep them all the time, while local variables get deleted after the code is executed.
Posts: 2,938
Threads: 162
Joined: May 2010
Posts: 1,047
Threads: 23
Joined: Jun 2009
I didn't research it but it sounds logically that variables created and then destroyed let you have more ram, however you have some performance loss.
PAWN is single threaded so if you're going to do a thousand times new string[256]; in each callback, why not make one global string? saves performance and time.(+amx size will be smaller)
Posts: 107
Threads: 6
Joined: May 2011
Reputation:
0
Yea', I decided to use a Global String in my script for most of my MySQL queries. Not sure if it's faster or not but it appears that way, I could be wrong though.
Posts: 1,047
Threads: 23
Joined: Jun 2009
Quote:
Originally Posted by thimo
Wouldnt it get bugged when 2 players use it at same time?
|
pawn Код:
new string[256];
public OnPlayerUpdate(playerid)
{
format(string,256,"Hello %d",playerid);
SendClientMessage(playerid,-1,string);
return 1;
}
Will work totally fine.