* apply patch by Blaise.ru to pass the record name for an internal record more efficiently

git-svn-id: trunk@42653 -
This commit is contained in:
svenbarth 2019-08-11 17:26:44 +00:00
parent 955ebf2f09
commit fc46b6c57c

View File

@ -374,7 +374,7 @@ interface
variantrecdesc : pvariantrecdesc; variantrecdesc : pvariantrecdesc;
isunion : boolean; isunion : boolean;
constructor create(const n:string; p:TSymtable);virtual; constructor create(const n:string; p:TSymtable);virtual;
constructor create_global_internal(n: string; packrecords, recordalignmin: shortint); virtual; constructor create_global_internal(const n: string; packrecords, recordalignmin: shortint); virtual;
function add_field_by_def(const optionalname: TIDString; def: tdef): tsym; function add_field_by_def(const optionalname: TIDString; def: tdef): tsym;
procedure add_fields_from_deflist(fieldtypes: tfplist); procedure add_fields_from_deflist(fieldtypes: tfplist);
constructor ppuload(ppufile:tcompilerppufile); constructor ppuload(ppufile:tcompilerppufile);
@ -4783,33 +4783,38 @@ implementation
end; end;
constructor trecorddef.create_global_internal(n: string; packrecords, recordalignmin: shortint); constructor trecorddef.create_global_internal(const n: string; packrecords, recordalignmin: shortint);
var var
name : string;
pname : pshortstring;
oldsymtablestack: tsymtablestack; oldsymtablestack: tsymtablestack;
where : tsymtable; where : tsymtable;
ts: ttypesym; ts: ttypesym;
definedname: boolean;
begin begin
{ construct name } { construct name }
definedname:=n<>''; if n<>'' then
if not definedname then pname:=@n
n:='$InternalRec'+tostr(current_module.deflist.count); else
begin
name:='$InternalRec'+tostr(current_module.deflist.count);
pname:=@name;
end;
oldsymtablestack:=symtablestack; oldsymtablestack:=symtablestack;
{ do not simply push/pop current_module.localsymtable, because { do not simply push/pop current_module.localsymtable, because
that can have side-effects (e.g., it removes helpers) } that can have side-effects (e.g., it removes helpers) }
symtablestack:=nil; symtablestack:=nil;
symtable:=trecordsymtable.create(n,packrecords,recordalignmin); symtable:=trecordsymtable.create(pname^,packrecords,recordalignmin);
symtable.defowner:=self; symtable.defowner:=self;
isunion:=false; isunion:=false;
inherited create(n,recorddef,true); inherited create(pname^,recorddef,true);
where:=current_module.localsymtable; where:=current_module.localsymtable;
if not assigned(where) then if not assigned(where) then
where:=current_module.globalsymtable; where:=current_module.globalsymtable;
where.insertdef(self); where.insertdef(self);
{ if we specified a name, then we'll probably want to look up the { if we specified a name, then we'll probably want to look up the
type again by name too -> create typesym } type again by name too -> create typesym }
if definedname then if n<>'' then
begin begin
ts:=ctypesym.create(n,self,true); ts:=ctypesym.create(n,self,true);
{ avoid hints about unused types (these may only be used for { avoid hints about unused types (these may only be used for