a Question to strpack
#4

Quote:
Originally Posted by ******
Посмотреть сообщение
A feature of PAWN rarely used in SA:MP (owed partially to the inability of certain natives to support it) is packed strings. Regular strings store one character per cell and a cell is 4 bytes long (making 256 long strings exactly a kilobyte in size), packed strings store 4 characters per cell:

Unpacked:

pawn Код:
new
    string[12] = "Hello there"; // 12 cells, 48 bytes

Packed:

pawn Код:
new
    string[12 char] = !"Hello there"; // 3 cells, 12 bytes
These strings are well documented in pawn-lang.pdf so I won't go into too much detail here, but if you have large arrays of strings to store it would be well worth your effort to read up on packed strings and use them for storage, if not manipulation. If this method were used on the ReturnModeratorCmd example above, combined with using a decent size string would reduce the memory consumption of that function from 1 kilobyte (1024 bytes) to 50 bytes, that's a reduction of over 2000%
Search next time.
Reply


Messages In This Thread
a Question to strpack - by xerox8521 - 18.11.2011, 19:42
Re: a Question to strpack - by GangsTa_ - 18.11.2011, 20:17
AW: a Question to strpack - by xerox8521 - 18.11.2011, 20:27
Re: a Question to strpack - by Calgon - 18.11.2011, 20:33
AW: a Question to strpack - by xerox8521 - 18.11.2011, 20:36
Re: a Question to strpack - by MP2 - 18.11.2011, 23:57
Re: a Question to strpack - by Calgon - 19.11.2011, 00:26

Forum Jump:


Users browsing this thread: 2 Guest(s)