[fpc-devel] Performance of string handling in trunk

Michael Schnell mschnell at lumino.de
Thu Jun 27 13:28:40 CEST 2013


On 06/26/2013 06:19 PM, Hans-Peter Diettrich wrote:
>
> A string variable has no encoding type stored. Only non-empty strings 
> have an encoding.

Sorry for bad wording. Not the String variable itself (as same is just a 
pointer to the String Record) but the string Record it points to has the 
field for storing the dynamic encoding type. The string variable of 
course only has it's static encoding type at compile time.

Nonetheless you need to know that a string variable with one (normal) 
encoding type that points to a String Record that holds a different 
encoding type should never happen and might trigger unpredictable behavior.

>
> No string can have an encoding of $FFFF.

Why then is same defined as a constant ?

I assume that when creating a RawByteString variable and not assigning a 
normal string to same, it will point to a a string Record holding an  
encoding Type $FFFF, but I might be wrong regarding this implementation 
detail.

You might use DXE and test

var s;: RawByteString.
..
setlength(s, 10);   //force allocation if a String record.
...

This only gets interesting when using RawByteString not in the way we 
discussed right now but according to what the name suggests - but this 
is jet another issue.

-Michael





More information about the fpc-devel mailing list