[fpc-pascal] Re: UnicodeString comparison performance

Jonas Maebe jonas.maebe at elis.ugent.be
Mon Jul 23 16:23:39 CEST 2012


On 23 Jul 2012, at 10:58, OBones wrote:

> leledumbo wrote:
>> I look at the generated code and in the direct one there's additional
>> overhead of decrementing the reference counter on each iteration.
> I see it too now (I forgot about the -a option).
> I can understand why there is a call to the decrementer outside the loop when using the variable, but I don't understand why it pushes it completely out of the loop. I mean, isn't there a reference count problem here?

Reference counted data types are returned by reference in a location passed to the function by the caller. The compiler here passes the address of S to the function, so that when assigning something to the function result inside the function, S' reference count gets decreased.

The fact that when the result is returned in a temp, this temp also gets finalized on the caller side before the call is just a code generator inefficiency. I've changed that in trunk.


Jonas


More information about the fpc-pascal mailing list