Thread: String Slicing
View Single Post
sawce
The null pointer exception error and virtual machine bug
Join Date: Oct 2004
Old 10-01-2007 , 03:19   Re: String Slicing
Reply With Quote #10

Quote:
Originally Posted by _Master_ View Post
It's been a while since I looked into amxx source code so I could be wrong about this: doesn't amxx declare the buffer for string manipulations as static?!?
wut

If you're talking about how the core and modules read a string from a Pawn script, then yes and no, although declaring a heavily used variable static doesn't have as huge of a performance benefit in C as it does with Pawn - the string buffer is declared static internally for convenience.

However, Pawn stores 1 character from each string in one cell. One character in a C-style string is 1 byte long, there are (normally) 4 bytes in one cell - the extra 3 bytes are wasted. The routine to read a Pawn string inside of core or a module has to basically make its own copy of the string, and manipulate it from there.

However, that is assuming the string needs to be passed to a routine expecting a C-style string, a lot of the natives are written to read and change the string as a Pawn style string, so it doesn't have to do the fairly expensive copy back - the inclusion of formatex() was an example of this optimization.
__________________
fyren sucks
sawce is offline