Skip to content

Code cleanup at function InitInheritedComponent

Function InitInheritedComponent contains the following code:

function InitInheritedComponent(Instance: TComponent; RootAncestor: TClass): Boolean;
Var
  I : Integer;
begin
  I:=0;
  if not Assigned(InitHandlerList) then begin
    Result := True;
    Exit;
  end;
  Result:=False;
  With InitHandlerList do
    begin
    I:=0;
    // Instance is the normally the lowest one, so that one should be used when searching.
    While Not result and (I<Count) do
      begin
      If (Instance.InheritsFrom(TInitHandler(Items[i]).AClass)) then
        Result:=TInitHandler(Items[i]).AHandler(Instance,RootAncestor);
      Inc(I);
      end;
    end;
end;

It can be noticed that a single presence of I:=0; line is enough. The following patch removes the first occurrence.

patch.diff

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information