a Question to strpack - 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)
+--- Thread: a Question to strpack (
/showthread.php?tid=297990)
a Question to strpack -
xerox8521 - 18.11.2011
Does strpack und unpack make any perfomance ? and Hows be supposed to be used
Re: a Question to strpack -
GangsTa_ - 18.11.2011
https://sampwiki.blast.hk/wiki/Strpack
AW: a Question to strpack -
xerox8521 - 18.11.2011
well iv looked into that but iv never found a reason to use it ? Any performance difference between packed and normal ?
Re: a Question to strpack -
Calgon - 18.11.2011
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.
AW: a Question to strpack -
xerox8521 - 18.11.2011
thanks
Re: a Question to strpack -
MP2 - 18.11.2011
What are the DISadvantages of using packed strings?
Re: a Question to strpack -
Calgon - 19.11.2011
You have to unpack strings to re-format them, you have to pack them after formatting.
100 lines of code turns in to 140 lines of code with string packing (an attempt at an expression, not really true).