Efficient or NO? - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Efficient or NO? (
/showthread.php?tid=187208)
Efficient or NO? -
almighty - 01.11.2010
Hello guys, me again...
.... I was wondering, I have this enum:
Код:
enum PlayerData
{
Weapon0,
Weapon1,
Weapon2,
Weapon3,
Weapon4,
Weapon5,
Weapon6,
Weapon7,
Weapon8,
Weapon9,
Weapon10,
Weapon11,
}
If i want to save the data there, if i do this:
Код:
new string[128];
for(new I = 0; I<12; I++)
{
format(string,sizeof(string),"Weapon%",I);
dini_IntSet(FNAME,string,PlayerData[playerid][string])
}
Is it better, worse, or the same than this:
Код:
dini_IntSet(FNAME,"Weapon0",PlayerData[playerid][Weapon0])
dini_IntSet(FNAME,"Weapon1",PlayerData[playerid][Weapon1])
dini_IntSet(FNAME,"Weapon2",PlayerData[playerid][Weapon2])
dini_IntSet(FNAME,"Weapon3",PlayerData[playerid][Weapon3])
?
Re: Efficient or NO? -
Kwarde - 01.11.2010
Use the second one
I ever tried the first one, it didn't work by me (or I did do it wrong)
and after that,
That won't work.
Use this:
pawn Код:
enum PData
{
Weapon0,
Weapon1,
Weapon2,
Weapon3,
Weapon4,
Weapon5,
Weapon6,
Weapon7,
Weapon8,
Weapon9,
Weapon10,
Weapon11,
}
new PlayerData[MAX_PLAYERS][PData];
Respuesta: Efficient or NO? -
almighty - 01.11.2010
O well... Thanks...
... Quick Answer...
Re: Efficient or NO? -
The_Moddler - 01.11.2010
It's the same.
pawn Код:
for(new i = 12; i > 12; i--)
{
static string[24];
format(string, 24, "Weapon%d", i);
dini_IntSet(FNAME, string, PlayerData[playerid][string])
}
Re: Efficient or NO? -
Finn - 01.11.2010
It is not the same, just write those 12 lines by hand - ain't too tough job is it?
Re: Efficient or NO? -
The_Moddler - 01.11.2010
The loop is doing 12 writes.. the other method is doing 12 writes, it's the same.
Actually, the loop may be 0,002 ms slower.
Re: Efficient or NO? -
Finn - 01.11.2010
Yeah, the writing part is the only that matters, right?
Your method, using the loop, is 2 times slower (just tested it) than just having 12 lines of code.