mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-06-07 09:18:33 +02:00
* Speedup for ancestor lookup using sorted list
git-svn-id: trunk@10589 -
This commit is contained in:
parent
d5eec67b53
commit
b2253c0bd9
@ -1239,7 +1239,7 @@ type
|
|||||||
FDestroyDriver: Boolean;
|
FDestroyDriver: Boolean;
|
||||||
FRootAncestor: TComponent;
|
FRootAncestor: TComponent;
|
||||||
FPropPath: String;
|
FPropPath: String;
|
||||||
FAncestors: TFPList;
|
FAncestors: TStringList;
|
||||||
FAncestorPos: Integer;
|
FAncestorPos: Integer;
|
||||||
FChildPos: Integer;
|
FChildPos: Integer;
|
||||||
FOnFindAncestor: TFindAncestorEvent;
|
FOnFindAncestor: TFindAncestorEvent;
|
||||||
|
@ -402,7 +402,7 @@ end;
|
|||||||
// Used as argument for calls to TComponent.GetChildren:
|
// Used as argument for calls to TComponent.GetChildren:
|
||||||
procedure TWriter.AddToAncestorList(Component: TComponent);
|
procedure TWriter.AddToAncestorList(Component: TComponent);
|
||||||
begin
|
begin
|
||||||
FAncestors.Add(Component);
|
FAncestors.AddObject(Component.Name,Component);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TWriter.DefineProperty(const Name: String;
|
procedure TWriter.DefineProperty(const Name: String;
|
||||||
@ -498,25 +498,17 @@ end;
|
|||||||
procedure TWriter.DetermineAncestor(Component : TComponent);
|
procedure TWriter.DetermineAncestor(Component : TComponent);
|
||||||
|
|
||||||
Var
|
Var
|
||||||
S : String;
|
|
||||||
I : Integer;
|
I : Integer;
|
||||||
C : TComponent;
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
// Should be set only when we write an inherited with children.
|
// Should be set only when we write an inherited with children.
|
||||||
|
|
||||||
if Not Assigned(FAncestors) then
|
if Not Assigned(FAncestors) then
|
||||||
exit;
|
exit;
|
||||||
FAncestor:=nil;
|
I:=FAncestors.IndexOf(Component.Name);
|
||||||
S:=UpperCase(Component.Name);
|
If (I=-1) then
|
||||||
I:=0;
|
FAncestor:=Nil
|
||||||
While (FAncestor=Nil) and (I<FAncestors.Count) do
|
else
|
||||||
begin
|
FAncestor:=TComponent(FAncestors.Objects[i]);
|
||||||
C:=TComponent(FAncestors[i]);
|
|
||||||
if (S=UpperCase(C.Name)) then
|
|
||||||
FAncestor:=C;
|
|
||||||
Inc(I);
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TWriter.DoFindAncestor(Component : TComponent);
|
procedure TWriter.DoFindAncestor(Component : TComponent);
|
||||||
@ -537,9 +529,9 @@ end;
|
|||||||
procedure TWriter.WriteComponent(Component: TComponent);
|
procedure TWriter.WriteComponent(Component: TComponent);
|
||||||
|
|
||||||
var
|
var
|
||||||
i : integer;
|
|
||||||
SA : TPersistent;
|
SA : TPersistent;
|
||||||
SR : TComponent;
|
SR : TComponent;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
SR:=FRoot;
|
SR:=FRoot;
|
||||||
SA:=FAncestor;
|
SA:=FAncestor;
|
||||||
@ -565,7 +557,7 @@ procedure TWriter.WriteChildren(Component : TComponent);
|
|||||||
|
|
||||||
Var
|
Var
|
||||||
SRoot, SRootA : TComponent;
|
SRoot, SRootA : TComponent;
|
||||||
SList : TFPList;
|
SList : TStringList;
|
||||||
begin
|
begin
|
||||||
// Write children list.
|
// Write children list.
|
||||||
// While writing children, the ancestor environment must be saved
|
// While writing children, the ancestor environment must be saved
|
||||||
@ -579,10 +571,11 @@ begin
|
|||||||
FRoot:=Component;
|
FRoot:=Component;
|
||||||
if (FAncestor is TComponent) then
|
if (FAncestor is TComponent) then
|
||||||
begin
|
begin
|
||||||
FAncestors:=TFPList.Create;
|
FAncestors:=TStringList.Create;
|
||||||
if csInline in TComponent(FAncestor).ComponentState then
|
if csInline in TComponent(FAncestor).ComponentState then
|
||||||
FRootAncestor := TComponent(FAncestor);
|
FRootAncestor := TComponent(FAncestor);
|
||||||
TComponent(FAncestor).GetChildren(@AddToAncestorList,FRootAncestor);
|
TComponent(FAncestor).GetChildren(@AddToAncestorList,FRootAncestor);
|
||||||
|
FAncestors.Sorted:=True;
|
||||||
end;
|
end;
|
||||||
try
|
try
|
||||||
Component.GetChildren(@WriteComponent, FRoot);
|
Component.GetChildren(@WriteComponent, FRoot);
|
||||||
|
Loading…
Reference in New Issue
Block a user