Morning.
Several months ago someone on this list mentioned that GPC was slower than other Pascal compilers.
Would like to comment on one possible cause for this. Please keep in mind than am not familiar with GPC internals. (i.e. Ignorance has never stopped opinions in the past:)
One possible cause for this lack of speed may be due to string handling. The schema used for strings has an allocated length (max allowed) but does not seem to have an actual length. In C derived languages the famous ASCII 0 is used as terminator.
If an actual length is not kept, then adding one may improve performance. This would imply that the string manipulation routines in the libraries would also have to be changed.
Past experience in C has shown that finding ASCII 0 in strings can take 15% to 25% of CPU time, depending on type of manipulations used.
Another trick that could improve string performance is reference counting.
This technique keeps a count of the number of string variable that reference a unique string. For example:
A := 'Kangaroos have nice tails';
The string schema would contain the allotted length, the actual string length and a reference of 1. The one indicates that one variable, A, is using the string.
B := A;
The reference count would be incremented by 1. The B structure would simply point to the same physical memory location as it would in variable A. The physical memory would contain the schema.
B := B + ' in spring';
Would cause a new string to be created with the added text. The string specific references in both cases would now become 1 such that:
A := 'Kangaroos have nice tails'; B := 'Kangaroos have nice tails in spring';
When a variable goes out of scope, the reference count for the actual string decrements. When a reference hits 0 the physical string can then be garbage collected.
This technique is used by Borland.
Just my 3.42 cents (Canadian)
thanx p davidson