[fpc-devel] Faster InitObject

Amir amir at aavani.net
Fri Feb 24 00:54:38 CET 2012


On 02/23/2012 02:20 PM, Hans-Peter Diettrich wrote:
> Amir schrieb:
>
>> The performance of FillChar is not my problem, The main issue in my
>> case is that my class has a big array defined inside it. I developed
>> my code such that this array does not need to be initialized with zero
>> initially (I have not assumed anything about the content of this array).
>> But the InitInstance function, initialize the array with zero.
>>
>> I can see a simple solution to resolve my problem. I can change the
>> array, in my class, to a dynamic array or pointer or ...
>> But what if I had, let's say, many variables inside my class? Or a big
>> data structure?
>
> The initialization of every class instance is a major improvement over
> e.g. C++ classes. I'd say that you should accept it, instead of
> searching for workarounds, with hard to predict effects in the remaining
> code.

I understand that, but I usually forget about it and initialize all my 
variables to 0 in constructor ;).


Amir



More information about the fpc-devel mailing list