WSRegisterClass apparent inefficiency lazarus / 31-LCL ---------------------------------------------------------------------- BrunoK · 2020-06-17 14:43 While testing issue https://bugs.freepascal.org/view.php?id=37216 I fell on TControl.WSRegisterClass  and TWinControl.WSRegisterClass that are called repeatedly via TLCLComponent.NewInstance when creating a TLCLComponent descendant instance. Taking a TControl as TLCLComponent descendant, is there a reason to not mark the class as registered the first time TControl.WSRegisterClass is called ? Using RegisterControl (in \lcl\widgetset\wscontrols.pp) as a model, I apparently successfully managed to skip lots of code repetition at runtime, specifically the repeated calls to RegisterPropertyToSkip that need list scanning every time a NewInstance  is created. The code I have now for TControl and TWinControl WSRegisterClass are the following ones : Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i class procedure TControl.WSRegisterClass;const  Registered : boolean = False;begin  if Registered then    Exit;  inherited WSRegisterClass;  RegisterControl;  RegisterPropertyToSkip(TControl, 'AlignWithMargins', 'VCL compatibility property', '');  RegisterPropertyToSkip(TControl, 'Ctl3D',            'VCL compatibility property', '');  RegisterPropertyToSkip(TControl, 'ParentCtl3D',      'VCL compatibility property', '');  RegisterPropertyToSkip(TControl, 'IsControl',        'VCL compatibility property', '');  RegisterPropertyToSkip(TControl, 'DesignSize',       'VCL compatibility property', '');  RegisterPropertyToSkip(TControl, 'ExplicitLeft',     'VCL compatibility property', '');  RegisterPropertyToSkip(TControl, 'ExplicitHeight',   'VCL compatibility property', '');  RegisterPropertyToSkip(TControl, 'ExplicitTop',      'VCL compatibility property', '');  RegisterPropertyToSkip(TControl, 'ExplicitWidth',    'VCL compatibility property', '');  Registered := True;end;Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i class procedure TWinControl.WSRegisterClass;const  Registered : boolean = False;begin  if Registered then    Exit;  inherited WSRegisterClass;  RegisterWinControl;  RegisterPropertyToSkip(TWinControl, 'ParentDoubleBuffered', 'VCL compatibility property', '');  RegisterPropertyToSkip(TWinControl, 'ImeMode', 'VCL compatibility property', '');  RegisterPropertyToSkip(TWinControl, 'ImeName', 'VCL compatibility property', '');  Registered := True;end;I rebuild lazarus and every thing works correctly. Is there an obvious reason that it would create troubles ? Lazarus quite recent trunk (+/- changes regarding TScrollBar, IntitalSetupDialog, Options.Environment options).  FPC 3.0.4 (the mac os one) from svn + some mods. Windows 10 Pro x64 (v. 1903 / 18362.418) and for occasional Linux tests, Manjaro (QT5 and GTK2) ---------------------------------------------------------------------- jamie · 2020-06-18 22:41 I would go as far as implementing an overloaded version of that... RegisterPropertyToSkip(TControl, ArrayofItems , 'VCL_...….',''); ---------------------------------------------------------------------- Martin_fr · 2020-06-18 23:12 I would not expect this to be a problem. And I would say something should be done. Just a few personal thoughts: - I am not sure, if we need to (or should) check twice. (In WSRegisterClass and in Register). - Maybe the RegisterPropertyToSkip can be moved to Register. Though the purpose of that unit is different.... - Or if Register is only called by WSRegisterClass, then a check in WSRegisterClass  would be enough (but then they all need to move, to keep it from getting confusing....)