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.

While it may be possible to move elements, which do not deserve an initialization, out of the instance, this solution adds time to *every* later usage, and may require methods (calls!) to address these values as properties.

Another solution could move all uninitialized members to the end of the instance, and to initialize only the first part of the instance. But such modified behaviour will also affect all derived classes, whose added members then either stay uninitialized (what's unexpected), or will revert your optimization of the base class.

DoDi

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

Reply via email to