29.09.2010, 14:24
(
Last edited by Slice; 29/09/2010 at 02:40 PM.
)
hey.. I put code too! : (
http://forum.sa-mp.com/showpost.php?...3&postcount=19
btw, to create arrays with unsigned 8bit integers, simply use the "char" keyword.
thanks Y_Less for reminding me about the curly brackets ![Cheesy](images/smilies/biggrin.png)
Say you have around 10 arrays size 500 that don't have values higher than 255 or lower than 0. Storing those in 4-byte cells would use a total of 20000 bytes, roughly 20kb. If you were using the arrays for packed strings, you would use only 5000 bytes (5 kb).
Also,
For arrays containing onle true/false, you could store those in each bit; resulting in 32 true/false values per cell. For a bit array size 500, would need only 16 cells! Comparing that to a normal array, you would save roughly 2kb for just one array!
http://forum.sa-mp.com/showpost.php?...3&postcount=19
btw, to create arrays with unsigned 8bit integers, simply use the "char" keyword.
pawn Code:
new array[ 4 char ];
array{ 0 } = 10;
array{ 1 } = 20;
array{ 2 } = 30;
array{ 3 } = 40;
printf( "%d %d %d %d", array{ 0 }, array{ 1 }, array{ 2 }, array{ 3 } );
![Cheesy](images/smilies/biggrin.png)
Quote:
I'm not so sure about the second method though. Im all for saving memory, but i dont think the speed difference would be worth it for 4 unsigned 8 bit integers. That's just my view though, there's nothing wrong with it at all. To be honest, i never even thought about this once. Its pretty neat at the very least.
|
Also,
For arrays containing onle true/false, you could store those in each bit; resulting in 32 true/false values per cell. For a bit array size 500, would need only 16 cells! Comparing that to a normal array, you would save roughly 2kb for just one array!