mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-11-20 14:09:36 +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
|
||||
(srsymtable.moduleid<>FProcsymtable.moduleid) then
|
||||
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
|
||||
srsym:=tsym(srsymtable.FindWithHash(hashedid));
|
||||
if assigned(srsym) and
|
||||
@ -2343,7 +2348,8 @@ implementation
|
||||
pt:=tcallparanode(FParaNode);
|
||||
while assigned(pt) do
|
||||
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);
|
||||
pt:=tcallparanode(pt.right);
|
||||
end;
|
||||
|
||||
@ -1221,8 +1221,10 @@ implementation
|
||||
block_type:=old_block_type;
|
||||
if assigned(pd) then
|
||||
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);
|
||||
pd.procsym.owner.includeoption(sto_has_operator);
|
||||
if pd.parast.symtablelevel>normal_function_level then
|
||||
Message(parser_e_no_local_operator);
|
||||
if isclassmethod then
|
||||
|
||||
@ -532,7 +532,8 @@ type
|
||||
{ options for symtables }
|
||||
tsymtableoption = (
|
||||
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;
|
||||
|
||||
|
||||
@ -535,7 +535,8 @@ const
|
||||
symtblopts=ord(high(tsymtableoption)) + 1;
|
||||
symtblopt : array[1..symtblopts] of tsymtblopt=(
|
||||
(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
|
||||
options : tsymtableoptions;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user