LCL: Use a faster compare method for case-insensitive StringList.

git-svn-id: trunk@64443 -
This commit is contained in:
juha 2021-01-30 18:36:54 +00:00
parent d0ac16bcc5
commit a542627231
15 changed files with 46 additions and 36 deletions

View File

@ -848,7 +848,7 @@ begin
ControlStyle := ControlStyle - [csCaptureMouse];
with GetControlClassDefaultSize do
SetInitialBounds(0, 0, CX, CY);
FItems := TStringlist.Create;
FItems := TStringListUTF8Fast.Create;
FItemIndex := -1;
FItemWidth := 0;
FMaxLength := 0;

View File

@ -61,10 +61,10 @@ end;
constructor TScreen.Create(AOwner : TComponent);
begin
inherited Create(AOwner);
FFonts := TStringlist.Create;
FFonts := TStringListUTF8Fast.Create;
FCursorMap := TMap.Create(its4, SizeOf(HCursor));
FMonitors := TMonitorList.Create;
TStringlist(FFonts).Sorted := True;
//TStringlist(FFonts).Sorted := True; Will be sorted in GetFonts
FCustomForms := TFPList.Create;
FCustomFormsZOrdered := TFPList.Create;
FFormList := TFPList.Create;

View File

@ -550,12 +550,12 @@ end;
------------------------------------------------------------------------------}
procedure TGtkListStoreStringList.Sort;
var
sl: TStringList;
sl: TStringListUTF8Fast;
OldSorted: Boolean;
begin
BeginUpdate;
// sort internally (sorting in the widget would be slow and unpretty ;)
sl := TStringList.Create;
sl := TStringListUTF8Fast.Create;
sl.Assign(Self);
sl.Sort;
OldSorted := Sorted;
@ -623,7 +623,7 @@ begin
// => don't change if the content is already the same
if Sorted then
begin
CmpList := TStringList.Create;
CmpList := TStringListUTF8Fast.Create;
CmpList.Assign(TStrings(Source));
TStringList(CmpList).Sort;
end

View File

@ -497,11 +497,11 @@ end;
------------------------------------------------------------------------------}
procedure TGtkListStringList.Sort;
var
sl: TStringList;
sl: TStringListUTF8Fast;
begin
BeginUpdate;
// sort internally (sorting in the widget would be slow and unpretty ;)
sl:=TStringList.Create;
sl:=TStringListUTF8Fast.Create;
sl.Assign(Self);
sl.Sort; // currently this is quicksort ->
// Disadvantages: - worst case on sorted list
@ -517,7 +517,7 @@ function TGtkListStringList.IsEqual(List: TStrings;
CompareObjects: boolean): boolean;
var
i, Cnt: integer;
CmpList: TStringList;
CmpList: TStringListUTF8Fast;
begin
if List=Self then begin
Result:=true;
@ -528,7 +528,7 @@ begin
Cnt:=Count;
if (Cnt<>List.Count) then exit;
BeginUpdate;
CmpList:=TStringList.Create;
CmpList:=TStringListUTF8Fast.Create;
try
CmpList.Assign(List);
CmpList.Sorted:=FSorted;

View File

@ -3670,7 +3670,7 @@ var
Info: TSearchRec;
DirName: PChar;
Dir: string;
StrList: TStringList;
StrList: TStringListUTF8Fast;
CurFileMask: String;
procedure Add(List: PGtkCList; const s: string);
@ -3691,7 +3691,7 @@ var
end;
begin
StrList := TStringList.Create;
StrList := TStringListUTF8Fast.Create;
dirs := PGtkCList(FileSelection^.dir_list);
files := PGtkCList(FileSelection^.file_list);
DirName := gtk_file_selection_get_filename(FileSelection);

View File

@ -24,7 +24,7 @@ uses
// RTL, FCL, libs
Math, Sysutils, Classes, GLib2, Gtk2, Gdk2, Gdk2pixbuf,
// LazUtils
LazTracer,
LazTracer, LazUTF8,
// LCL
LCLType, LCLIntf, LMessages, Controls, Graphics, ComCtrls, StdCtrls, Forms,
ImgList, InterfaceBase,

View File

@ -1745,7 +1745,7 @@ begin
New(Widgets);
with Widgets^ do
begin
ItemCache := TStringList.Create;
ItemCache := TStringListUTF8Fast.Create;
Images := nil;
OldTreeSelection := nil;

View File

@ -21,7 +21,12 @@ unit gtk3private;
interface
uses Classes, SysUtils, Controls, LazGtk3, LazGObject2, LazGLib2;
uses
Classes, SysUtils,
// LazUtils
LazUTF8,
// LCL
Controls, LazGtk3, LazGObject2, LazGLib2;
type
@ -315,12 +320,12 @@ end;
------------------------------------------------------------------------------}
procedure TGtkListStoreStringList.Sort;
var
sl: TStringList;
sl: TStringListUTF8Fast;
OldSorted: Boolean;
begin
BeginUpdate;
// sort internally (sorting in the widget would be slow and unpretty ;)
sl := TStringList.Create;
sl := TStringListUTF8Fast.Create;
sl.Assign(Self);
sl.Sort;
OldSorted := Sorted;
@ -388,7 +393,7 @@ begin
// => don't change if the content is already the same
if Sorted then
begin
CmpList := TStringList.Create;
CmpList := TStringListUTF8Fast.Create;
CmpList.Assign(TStrings(Source));
TStringList(CmpList).Sort;
end

View File

@ -558,7 +558,7 @@ end;
procedure TQtComboStrings.Assign(Source: TPersistent);
var
AList: TStringList;
AList: TStringListUTF8Fast;
begin
if (Source = Self) or (Source = nil) then Exit;
if Assigned(FWinControl) and (FWinControl.HandleAllocated) then
@ -566,7 +566,7 @@ begin
FOwner.BeginUpdate;
if Sorted then
begin
AList := TStringList.Create;
AList := TStringListUTF8Fast.Create;
try
AList.Assign(Source);
AList.Sort;

View File

@ -111,7 +111,7 @@ type
FWidgetNeedFontColorInitialization: Boolean;
FChildOfComplexWidget: TChildOfComplexWidget;
FOwnWidget: Boolean;
FProps: TStringList;
FProps: TStringListUTF8Fast;
FPaintData: TPaintData;
FCentralWidget: QWidgetH;
FContext: HDC;
@ -5643,8 +5643,7 @@ var
begin
if FProps=nil then
begin
FProps:=TStringList.Create;
//FProps.CaseSensitive:=false;
FProps:=TStringListUTF8Fast.Create;
FProps.Sorted:=true;
end;
i := Fprops.IndexOf(AnIndex);

View File

@ -126,12 +126,13 @@ interface
{$MODE DELPHI}
uses
Classes, SysUtils,
LazUTF8,
LCLType, LCLStrConsts, LCLIntf, InterfaceBase,
{$IFDEF MSWINDOWS}
Windows, CommCtrl, Messages,
{$ENDIF}
LResources, Classes, SysUtils,
Menus, Graphics, Forms, Controls, StdCtrls, ExtCtrls, Buttons;
LResources, Menus, Graphics, Forms, Controls, StdCtrls, ExtCtrls, Buttons;
{$IFDEF MSWINDOWS}
var
@ -1022,7 +1023,7 @@ begin
end;
// add selection list or query editor
if Selection<>'' then begin
List := TStringList.Create;
List := TStringListUTF8Fast.Create;
try
Dialog.Form.Combo := TComboBox.Create(Dialog.Form);
with Dialog.Form.Combo do begin

View File

@ -1248,7 +1248,7 @@ begin
fcPenWidth :=0;
fcPenStyle :=psSolid;
fHeader:=TStringList.Create;
fHeader:=TStringListUTF8Fast.Create;
fBuffer:=TstringList.Create;
fDocument:=TStringList.Create;

View File

@ -17,7 +17,7 @@ interface
uses
Classes, SysUtils, Math,
// LazUtils
Maps;
Maps, LazUTF8;
type
TUnicodeBlock = record
@ -44,7 +44,7 @@ type
FGlyphs: TMap;
FBlocks: array of TUnicodeBlock;
FEncodings: array of Integer;
FOutLst, FBaseFonts,FEncodedFonts,FUsedFonts: TStringList;
FOutLst, FBaseFonts, FEncodedFonts, FUsedFonts: TStringList;
FLastFontIndex: Integer;
FFont: string;
procedure CountPSChars;
@ -67,7 +67,7 @@ type
property Font: string read FFont write SetFont;
property FontSize: Integer read FFontSize write SetFontSize;
property FOntStyle: Integer read FFontStyle write SetFontStyle;
property OutLst: TStringlist read FOutLst write FOutLst;
property OutLst: TStringList read FOutLst write FOutLst;
end;
implementation
@ -294,9 +294,9 @@ end;
constructor TPsUnicode.create;
begin
inherited create;
FBaseFonts := TStringList.Create;
FEncodedFonts := TStringList.Create;
FUsedFonts := TStringList.Create;
FBaseFonts := TStringListUTF8Fast.Create;
FEncodedFonts := TStringListUTF8Fast.Create;
FUsedFonts := TStringListUTF8Fast.Create;
FLastFontIndex := -1;
FFontSize := 12;
end;

View File

@ -22,7 +22,12 @@ unit Printers;
interface
uses
Classes, SysUtils, LCLProc, Graphics;
Classes, SysUtils,
// LazUtils
LazLoggerBase, LazUTF8,
// LCL
LCLProc, Graphics;
type
TPrinter = Class;
EPrinter = class(Exception);
@ -694,7 +699,7 @@ end;
function TPrinter.GetPrinters: TStrings;
begin
if not Assigned(fPrinters) then
fPrinters:=TStringList.Create;
fPrinters:=TStringListUTF8Fast.Create;
Result:=fPrinters;
//Only 1 initialization

View File

@ -873,7 +873,7 @@ begin
with TFileItem(Files.Objects[i]) do DoAddItem(FBasePath, FileInfo, CanAdd);
if CanAdd then
begin
NewNode := Items.AddChildObject(ANode, Files.Strings[i], nil);
NewNode := Items.AddChildObject(ANode, Files[i], nil);
TShellTreeNode(NewNode).FFileInfo := TFileItem(Files.Objects[i]).FileInfo;
TShellTreeNode(NewNode).SetBasePath(TFileItem(Files.Objects[i]).FBasePath);