Hans-Peter Diettrich wrote:
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. When it is also known that 255 character limit won't be exceeded, ShortString is nearly an ideal choice.

In many cases (almost all I found) the strings are duplicated when assigned, because the given dynamic strings disallow to simply copy the reference.

IMO P[Short]Strings only were useful when the referenced string shall be changed later, with that change reflected automatically in all references. Since this seems not to occur anywhere, I'd suggest to replace or retype PShortString by [Ansi]String.

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".

Regards,
Sergei
_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply via email to