fcl-passrc: do not allocate a temp list

(cherry picked from commit f50e6dfe8e)
This commit is contained in:
mattias 2022-03-23 15:08:42 +01:00 committed by Mattias Gaertner
parent 224ba9844d
commit b75ad2f4c9

View File

@ -7379,7 +7379,7 @@ begin
for i:=OldCount to ARec.Members.Count-1 do for i:=OldCount to ARec.Members.Count-1 do
begin begin
CurEl:=TPasElement(ARec.Members[i]); CurEl:=TPasElement(ARec.Members[i]);
if CurEl.ClassType=TPasAttributes then continue; if CurEl.ClassType<>TPasVariable then continue;
if isClass then if isClass then
With TPasVariable(CurEl) do With TPasVariable(CurEl) do
VarModifiers:=VarModifiers + [vmClass]; VarModifiers:=VarModifiers + [vmClass];
@ -7457,16 +7457,13 @@ begin
for i:=OldCount to ARec.Members.Count-1 do for i:=OldCount to ARec.Members.Count-1 do
begin begin
CurEl:=TPasElement(ARec.Members[i]); CurEl:=TPasElement(ARec.Members[i]);
if CurEl.ClassType=TPasAttributes then continue; if CurEl.ClassType<>TPasVariable then continue;
if CurEl.ClassType=TPasVariable then
begin
if isClass then if isClass then
With TPasVariable(CurEl) do With TPasVariable(CurEl) do
VarModifiers:=VarModifiers + [vmClass]; VarModifiers:=VarModifiers + [vmClass];
Engine.FinishScope(stDeclaration,TPasVariable(CurEl)); Engine.FinishScope(stDeclaration,TPasVariable(CurEl));
end; end;
end; end;
end;
tkSquaredBraceOpen: tkSquaredBraceOpen:
if msPrefixedAttributes in CurrentModeswitches then if msPrefixedAttributes in CurrentModeswitches then
ParseAttributes(ARec,true) ParseAttributes(ARec,true)
@ -7610,16 +7607,16 @@ procedure TPasParser.ParseClassFields(AType: TPasClassType;
const AVisibility: TPasMemberVisibility; IsClassField: Boolean); const AVisibility: TPasMemberVisibility; IsClassField: Boolean);
Var Var
VarList: TFPList;
Element: TPasElement; Element: TPasElement;
I : Integer; I , OldCount: Integer;
isStatic : Boolean; isStatic : Boolean;
VarEl: TPasVariable; VarEl: TPasVariable;
Members: TFPList;
begin begin
VarList := TFPList.Create; Members:=AType.Members;
try OldCount:=Members.Count;
ParseInlineVarDecl(AType, VarList, AVisibility, False); ParseInlineVarDecl(AType, Members, AVisibility, False);
if CurToken=tkSemicolon then if CurToken=tkSemicolon then
begin begin
NextToken; NextToken;
@ -7629,13 +7626,11 @@ begin
else else
UngetToken; UngetToken;
end; end;
for i := 0 to VarList.Count - 1 do for i := OldCount to Members.Count - 1 do
begin begin
Element := TPasElement(VarList[i]); Element := TPasElement(Members[i]);
Element.Visibility := AVisibility; Element.Visibility := AVisibility;
AType.Members.Add(Element); if Element.ClassType<>TPasVariable then continue;
if (Element is TPasVariable) then
begin
VarEl:=TPasVariable(Element); VarEl:=TPasVariable(Element);
if IsClassField then if IsClassField then
Include(VarEl.VarModifiers,vmClass); Include(VarEl.VarModifiers,vmClass);
@ -7643,10 +7638,6 @@ begin
Include(VarEl.VarModifiers,vmStatic); Include(VarEl.VarModifiers,vmStatic);
Engine.FinishScope(stDeclaration,VarEl); Engine.FinishScope(stDeclaration,VarEl);
end; end;
end;
finally
VarList.Free;
end;
end; end;
procedure TPasParser.ParseMembersLocalTypes(AType: TPasMembersType; procedure TPasParser.ParseMembersLocalTypes(AType: TPasMembersType;