[fpc-pascal] TPersistent overhead

Graeme Geldenhuys mailinglists at geldenhuys.co.uk
Sat Mar 26 20:57:23 CET 2016


On 2016-03-26 04:45, Ryan Joseph wrote:
> unfortunately the way my code is written I need to basically make all
> my classes descend from TPersistent, even classes that don’t need
> RTTI information.

Depending on your needs, you don't need to descend from TPersistent just
to get RTTI information in your classes. Simply wrap a TObject
descendant with {$M+} and deactivate the RTTI after the class definition.

For example:

  {$M+}
  TtiVisited = class(TObject)
    ... define your class interface here...
  end;
  {$M-}


Now TtiVisited will have RTTI information compiled in.

Regards,
  - Graeme -

-- 
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

My public PGP key:  http://tinyurl.com/graeme-pgp



More information about the fpc-pascal mailing list