a Question to strpack
#1

Does strpack und unpack make any perfomance ? and Hows be supposed to be used
Reply
#2

https://sampwiki.blast.hk/wiki/Strpack
Reply
#3

well iv looked into that but iv never found a reason to use it ? Any performance difference between packed and normal ?
Reply
#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
#5

thanks
Reply
#6

What are the DISadvantages of using packed strings?
Reply
#7

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


Forum Jump:


Users browsing this thread: 2 Guest(s)