Skip to content

Simplified function TPasRecordType.IsAdvancedRecord: Boolean

by 'lagprogramming'.

packages/fcl-passrc/src/pastree.pp has

    function TPasRecordType.IsAdvancedRecord: Boolean;
     
    Var
      I : Integer;
      Member: TPasElement;
     
    begin
      Result:=False;
      I:=0;
      While (Not Result) and (I<Members.Count) do
        begin
        Member:=TPasElement(Members[i]);
        if (Member.Visibility<>visPublic) then exit(true);
        if (Member.ClassType<>TPasVariable) then exit(true);
        Inc(I);
        end;
    end;

The while loop contains a useless "(Not Result)" condition. The result is false at the loop entry and it's changed only using "exit(true);" statements. The attached patch changes "While (Not Result) and (I<Members.Count) do" to "While I<Members.Count do".

p.diff

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