mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-09 02:28:14 +02:00
* optimize additions of empty sets away if possible, part of #40384
This commit is contained in:
parent
edaee6f392
commit
e35403c3b8
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user