* optimize additions of empty sets away if possible, part of #40384

This commit is contained in:
florian 2024-03-10 10:47:24 +01:00
parent edaee6f392
commit e35403c3b8

View File

@ -3597,6 +3597,7 @@ implementation
temp : ttempcreatenode;
begin
result:=nil;
case nodetype of
equaln,unequaln,lten,gten:
begin
@ -4302,9 +4303,6 @@ implementation
end;
var
{$ifdef addstringopt}
hp : tnode;
{$endif addstringopt}
rd,ld : tdef;
i,i2 : longint;
lt,rt : tnodetype;
@ -4389,6 +4387,17 @@ implementation
end;
end;
{ get rid of adding empty sets generated by set constructors (s+([]+[..]))
this needs to be done before firstpass, else the set additions get already converted into calls }
if (resultdef.typ=setdef) and (nodetype=addn) and (right.nodetype=addn) and (is_emptyset(taddnode(right).left)) then
begin
result:=caddnode.create(addn,left,taddnode(right).right);
left:=nil;
taddnode(right).right:=nil;
exit;
end;
{ first do the two subtrees }
firstpass(left);
firstpass(right);