mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-11-21 02:19:40 +01:00
Small optimization for the search of operator overloads. Add a flag "sto_has_generic" to all symtables that contain an operator overload (the flag propagates up the owning symtables) and check this flag when searching for units with operators.
symconst.pas: + add "sto_has_operator" to "tsymtableoption" pdecsub.pas: + include the flag "sto_has_operator" for all operator declarations and their owning symtables htypechk.pas, tcallcandidates: * create_candidate_list: only check for operator overloads if the record does indeed declare some * collect_overloads_in_units: only check for operator overloads if the unit does indeed declare some utils/ppudump.pp: + respect the new "sto_has_operator" flag git-svn-id: trunk@23688 -
This commit is contained in:
parent
9198630ce3
commit
168c9d152f
@ -2280,7 +2280,12 @@ implementation
|
|||||||
(FProcsymtable.symtabletype in [globalsymtable,staticsymtable]) and
|
(FProcsymtable.symtabletype in [globalsymtable,staticsymtable]) and
|
||||||
(srsymtable.moduleid<>FProcsymtable.moduleid) then
|
(srsymtable.moduleid<>FProcsymtable.moduleid) then
|
||||||
break;
|
break;
|
||||||
if srsymtable.symtabletype in [localsymtable,staticsymtable,globalsymtable] then
|
if (srsymtable.symtabletype in [localsymtable,staticsymtable,globalsymtable]) and
|
||||||
|
(
|
||||||
|
(FOperator=NOTOKEN) or
|
||||||
|
(sto_has_operator in srsymtable.tableoptions)
|
||||||
|
)
|
||||||
|
then
|
||||||
begin
|
begin
|
||||||
srsym:=tsym(srsymtable.FindWithHash(hashedid));
|
srsym:=tsym(srsymtable.FindWithHash(hashedid));
|
||||||
if assigned(srsym) and
|
if assigned(srsym) and
|
||||||
@ -2343,7 +2348,8 @@ implementation
|
|||||||
pt:=tcallparanode(FParaNode);
|
pt:=tcallparanode(FParaNode);
|
||||||
while assigned(pt) do
|
while assigned(pt) do
|
||||||
begin
|
begin
|
||||||
if (pt.resultdef.typ=recorddef) then
|
if (pt.resultdef.typ=recorddef) and
|
||||||
|
(sto_has_operator in tabstractrecorddef(pt.resultdef).owner.tableoptions) then
|
||||||
collect_overloads_in_struct(tabstractrecorddef(pt.resultdef),ProcdefOverloadList,searchhelpers,anoninherited);
|
collect_overloads_in_struct(tabstractrecorddef(pt.resultdef),ProcdefOverloadList,searchhelpers,anoninherited);
|
||||||
pt:=tcallparanode(pt.right);
|
pt:=tcallparanode(pt.right);
|
||||||
end;
|
end;
|
||||||
|
|||||||
@ -1221,8 +1221,10 @@ implementation
|
|||||||
block_type:=old_block_type;
|
block_type:=old_block_type;
|
||||||
if assigned(pd) then
|
if assigned(pd) then
|
||||||
begin
|
begin
|
||||||
{ operators always need to be searched in all units }
|
{ operators always need to be searched in all units (that
|
||||||
|
contain operators) }
|
||||||
include(pd.procoptions,po_overload);
|
include(pd.procoptions,po_overload);
|
||||||
|
pd.procsym.owner.includeoption(sto_has_operator);
|
||||||
if pd.parast.symtablelevel>normal_function_level then
|
if pd.parast.symtablelevel>normal_function_level then
|
||||||
Message(parser_e_no_local_operator);
|
Message(parser_e_no_local_operator);
|
||||||
if isclassmethod then
|
if isclassmethod then
|
||||||
|
|||||||
@ -532,7 +532,8 @@ type
|
|||||||
{ options for symtables }
|
{ options for symtables }
|
||||||
tsymtableoption = (
|
tsymtableoption = (
|
||||||
sto_has_helper, { contains at least one helper symbol }
|
sto_has_helper, { contains at least one helper symbol }
|
||||||
sto_has_generic { contains at least one generic symbol }
|
sto_has_generic, { contains at least one generic symbol }
|
||||||
|
sto_has_operator { contains at least one operator overload }
|
||||||
);
|
);
|
||||||
tsymtableoptions = set of tsymtableoption;
|
tsymtableoptions = set of tsymtableoption;
|
||||||
|
|
||||||
|
|||||||
@ -535,7 +535,8 @@ const
|
|||||||
symtblopts=ord(high(tsymtableoption)) + 1;
|
symtblopts=ord(high(tsymtableoption)) + 1;
|
||||||
symtblopt : array[1..symtblopts] of tsymtblopt=(
|
symtblopt : array[1..symtblopts] of tsymtblopt=(
|
||||||
(mask:sto_has_helper; str:'Has helper'),
|
(mask:sto_has_helper; str:'Has helper'),
|
||||||
(mask:sto_has_generic; str:'Has generic')
|
(mask:sto_has_generic; str:'Has generic'),
|
||||||
|
(mask:sto_has_operator; str:'Has operator')
|
||||||
);
|
);
|
||||||
var
|
var
|
||||||
options : tsymtableoptions;
|
options : tsymtableoptions;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user