Efficient or NO?
#1

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])
?

Reply
#2

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];
Reply
#3

O well... Thanks...... Quick Answer...
Reply
#4

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])
}
Reply
#5

It is not the same, just write those 12 lines by hand - ain't too tough job is it?
Reply
#6

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.
Reply
#7

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)