PDA

View Full Version : enum size +rep


iBots
21/04/2015, 06:34 PM
well i have made a system and this system enum has more than 10 things,each one thing is like this:

enum something
{
something1[1000],
something2[1000],
something3[1000],
something4[1000],
something5[1000],
something6[1000],
something7[1000],
something8[1000],
something9[1000],
something10[1000],
};
new info[max_somethings][something]; //max_something is 250

when i compile i get alot of size,how is it possible to optimize this enum and make it better?

JuanStone
21/04/2015, 06:40 PM
It is very large the size of the amx because you lot of memory in your variables, to optimize that you need to search the parts of code that used these variables, count the maximum number of characters(+1charcater null) and put it in place of " 1000 ".

iBots
21/04/2015, 06:46 PM
i said i am using these 1000 things,max is 1000 and you can get any thing from 0 to 1000

JuanStone
21/04/2015, 06:55 PM
I doubt that you save 10 thousand characters in each player, so that is the only solution friend, you must make good use of the variable strings, there is no other way to optimize, optimize in string variables is to declare the maximum number of characters to optimize and avoid wasting memory, if you occupy all of that memory there is no waste and don't need optimize anything :).

10,000 x 250 x 4 = 10000000

iBots
22/04/2015, 11:07 AM
anyone?

MP2
22/04/2015, 12:03 PM
What are you using these variables for?

Azula
22/04/2015, 12:08 PM
i dont know if this work
#define ze 0
something[ze char]

function(){

#if defined ze
#undef ze
#define ze 1000
#endif

}

admantis
22/04/2015, 12:10 PM
Packed strings (http://forum.sa-mp.com/showthread.php?t=480529)

iBots
22/04/2015, 02:19 PM
i am using them for creating cars and objects and,...

Pottus
22/04/2015, 03:00 PM
Seems to me you have excessive sized arrays re-evaluate what you actually need.

fuckingcruse
22/04/2015, 03:24 PM
In enum something10[1000] must not have " , "

Like this
something9[1000],
something10[1000]
};

admantis
22/04/2015, 06:38 PM
In enum something10[1000] must not have " , "

Like this
something9[1000],
something10[1000]
};

Wrong, enumerators support commas in the last element, however arrays don't, because you want to indicate what's the last element (not a requeriment with enums)

iBots
22/04/2015, 07:01 PM
i didnt really post this to get a reply with :"remove the ',' at the end,really?i typed this code when i made this post,i need a way to make it better.

Ahmad45123
22/04/2015, 08:11 PM
If you really need all that array than there is no way to optimize it unless lowering the size depending on what u need.