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,14 +7457,11 @@ 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 if isClass then
begin With TPasVariable(CurEl) do
if isClass then VarModifiers:=VarModifiers + [vmClass];
With TPasVariable(CurEl) do Engine.FinishScope(stDeclaration,TPasVariable(CurEl));
VarModifiers:=VarModifiers + [vmClass];
Engine.FinishScope(stDeclaration,TPasVariable(CurEl));
end;
end; end;
end; end;
tkSquaredBraceOpen: tkSquaredBraceOpen:
@ -7610,43 +7607,37 @@ 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;
isStatic:=CurTokenIsIdentifier('static'); isStatic:=CurTokenIsIdentifier('static');
if isStatic then if isStatic then
ExpectToken(tkSemicolon) ExpectToken(tkSemicolon)
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 VarEl:=TPasVariable(Element);
begin if IsClassField then
VarEl:=TPasVariable(Element); Include(VarEl.VarModifiers,vmClass);
if IsClassField then if isStatic then
Include(VarEl.VarModifiers,vmClass); Include(VarEl.VarModifiers,vmStatic);
if isStatic then Engine.FinishScope(stDeclaration,VarEl);
Include(VarEl.VarModifiers,vmStatic); end;
Engine.FinishScope(stDeclaration,VarEl);
end;
end;
finally
VarList.Free;
end;
end; end;
procedure TPasParser.ParseMembersLocalTypes(AType: TPasMembersType; procedure TPasParser.ParseMembersLocalTypes(AType: TPasMembersType;