[fpc-devel] dominant short strings in compiler source

Daniël Mantione daniel.mantione at freepascal.org
Tue May 16 20:27:58 CEST 2006



Op Tue, 16 May 2006, schreef Michael Van Canneyt:

> On Tue, 16 May 2006, L505 wrote:
> 
> There is no problem with short strings, except for external paths.
> 
> What IS a problem is that changing it to ansistrings will significantly slow down the compiler.
> For 2 reasons:
> 
> 1. It's heap based. There is a lot of memory manager overhead.
> 2. The implicit try...finally in each procedure that uses them introduces a memory penalty 
>    and a speed penalty.
> 
> So I would really advise against this change. There is no gain, except maybe for some 
> external path settings. identifiers etc: there short strings are more than enough.

A third reason: Most strings in the compiler are very short. I once did 
some statistics, allthough I can't remember the actual values, the 
percentage of strings < 8 bytes was well in the double digits.

The reason is that things like "var s,t:string" give very short 
identifier strings inside the compiler. Ansistrings are an expensive 
overhead here, for example even the 12 byte header counts heavily here.

Daniël


More information about the fpc-devel mailing list