[fpc-devel] PShortString

Sergei Gorelkin sergei_gorelkin at mail.ru
Fri Sep 10 14:22:59 CEST 2010


Daniël Mantione пишет:
> 
> 
> Op Fri, 10 Sep 2010, schreef Hans-Peter Diettrich:
> 
>> 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.
> 
> Ansistrings result allocation copy and deallocation during *processing*. 
> The use of ansistrings would make the compiler at least twice as slow 
> and quadruple its memory consumption.
> 
Also, don't forget that an AnsiString assignment, even when it doen not end up in memory 
allocations, will execute two intelocked instructions in multithreaded process.


Regards,
Sergei



More information about the fpc-devel mailing list