[fpc-devel] PShortString

Hans-Peter Diettrich DrDiettrich1 at aol.com
Fri Sep 10 02:49:13 CEST 2010


Sergei Gorelkin schrieb:

>> When dynamic strings are used all around, is the use of pointers to 
>> ShortString still recommended? (fmodule contains a lot of them)
>>
> Whenever you care about performance, you'll quickly realize that dynamic 
> strings are plain inappropriate.

The concrete use of PShortString strings is inappropriate in your sense, 
because it results in allocation, copy and deallocation of temporary 
strings in the code, in many places. This behaviour gave birth to my 
question.


> They provide fine-grained control over memory allocations, avoiding 
> implicit try..finally blocks and memory allocations for temps. Copying 
> still occurs, but with the highly optimized Move procedure it is pretty 
> cheap. So please don't change such things just because something is 
> "used all around".

All that would no more be needed after a decent redesign. Or the 
existing code is inappropriate, and all the mentioned operations can be 
removed from the source code, without affecting the behaviour and result.

DoDi




More information about the fpc-devel mailing list