mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-17 20:59:12 +02:00
Applied Patch from Bernd which uses a hash list instead of a StringList for css elements. This causes a big improvment in scrolling speed.
git-svn-id: trunk@34400 -
This commit is contained in:
parent
6c8ac2b3c8
commit
d84fb4ec3e
@ -96,7 +96,7 @@
|
|||||||
{ TCSSGlobalProps }
|
{ TCSSGlobalProps }
|
||||||
|
|
||||||
TCSSGlobalProps = class
|
TCSSGlobalProps = class
|
||||||
FElements: TStringList;
|
FElements: TFPObjectHashTable;
|
||||||
public
|
public
|
||||||
constructor Create;
|
constructor Create;
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
@ -482,6 +482,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
{ TCSSReader }
|
{ TCSSReader }
|
||||||
|
|
||||||
function TCSSReader.GetStatementElements(AStatement: String): TStringList;
|
function TCSSReader.GetStatementElements(AStatement: String): TStringList;
|
||||||
@ -870,15 +871,13 @@ end;
|
|||||||
|
|
||||||
constructor TCSSGlobalProps.Create;
|
constructor TCSSGlobalProps.Create;
|
||||||
begin
|
begin
|
||||||
FElements := TStringList.Create;
|
FElements := TFPObjectHashTable.Create(True);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
destructor TCSSGlobalProps.Destroy;
|
destructor TCSSGlobalProps.Destroy;
|
||||||
var
|
var
|
||||||
i: Integer;
|
i: Integer;
|
||||||
begin
|
begin
|
||||||
for i := 0 to FElements.Count-1 do
|
|
||||||
FElements.Objects[i].Free;
|
|
||||||
FElements.Free;
|
FElements.Free;
|
||||||
inherited Destroy;
|
inherited Destroy;
|
||||||
end;
|
end;
|
||||||
@ -889,21 +888,26 @@ var
|
|||||||
ElementName: String;
|
ElementName: String;
|
||||||
|
|
||||||
procedure LookForElement(const aElement: string);
|
procedure LookForElement(const aElement: string);
|
||||||
var
|
|
||||||
ElementIndex: Integer;
|
|
||||||
begin
|
begin
|
||||||
if length(ClassID) > 0 then
|
if length(ClassID) > 0 then
|
||||||
ElementName := Lowercase(aElement+'.'+ClassId)
|
ElementName := aElement + '.' + ClassId
|
||||||
else
|
else
|
||||||
ElementName := lowercase(aElement);
|
ElementName := aElement;
|
||||||
|
|
||||||
ElementIndex := FElements.IndexOf(ElementName);
|
// The element names are already lowercase, this is
|
||||||
|
// already done in the css parser. And the html parser
|
||||||
if ElementIndex>=0 then begin
|
// can only deliver its own built-in node names anyways.
|
||||||
result := TCSSProps(FElements.Objects[ElementIndex]);
|
// Also the names are not expected to be longer than
|
||||||
|
// ShortString (this would need to be a ridiculously
|
||||||
|
// long ClassID), should this ever happen then
|
||||||
|
// it would be silently truncated in the following
|
||||||
|
// type conversion to ShortString.
|
||||||
|
{$warning GetElement() is called a *lot* of times, this
|
||||||
|
is one of the hot spots, maybe some of the AnsiString
|
||||||
|
usage around here could be avoided a little bit}
|
||||||
|
Result := TCSSProps(FElements.Items[ElementName]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
end;
|
|
||||||
begin
|
begin
|
||||||
Result := nil;
|
Result := nil;
|
||||||
if (length(ClassID) = 0) and (length(AElementID) = 0) then
|
if (length(ClassID) = 0) and (length(AElementID) = 0) then
|
||||||
@ -916,7 +920,7 @@ begin
|
|||||||
if (Result = nil) and CreateIfNotExist then
|
if (Result = nil) and CreateIfNotExist then
|
||||||
begin
|
begin
|
||||||
Result := TCSSProps.Create;
|
Result := TCSSProps.Create;
|
||||||
FElements.AddObject(ElementName, Result);
|
FElements.Add(ElementName, Result);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -63,6 +63,7 @@ uses
|
|||||||
Translations,
|
Translations,
|
||||||
FileUtil,
|
FileUtil,
|
||||||
LConvEncoding,
|
LConvEncoding,
|
||||||
|
contnrs,
|
||||||
{$ELSE}
|
{$ELSE}
|
||||||
Windows,
|
Windows,
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
Loading…
Reference in New Issue
Block a user