BuildIntf, IdeIntf, LazUtils: Use a faster compare method for case-insensitive strings and StringLists.

git-svn-id: trunk@64464 -
This commit is contained in:
juha 2021-02-05 11:28:07 +00:00
parent 6a07271f31
commit e6d96156ec
12 changed files with 62 additions and 55 deletions

View File

@ -18,7 +18,7 @@ interface
uses uses
Classes, SysUtils, Classes, SysUtils,
// LazUtils // LazUtils
LazMethodList, LazMethodList, LazUTF8,
// BuildIntf // BuildIntf
IDEOptionsIntf; IDEOptionsIntf;
@ -479,7 +479,7 @@ constructor TLazCompilationToolOptions.Create(TheOwner: TLazCompilerOptions);
begin begin
FOwner:=TheOwner; FOwner:=TheOwner;
FCompileReasons:=crAll; // This default can be used in some comparisons. FCompileReasons:=crAll; // This default can be used in some comparisons.
FParsers:=TStringList.Create; FParsers:=TStringListUTF8Fast.Create;
end; end;
destructor TLazCompilationToolOptions.Destroy; destructor TLazCompilationToolOptions.Destroy;

View File

@ -681,12 +681,12 @@ type
FHint: string; FHint: string;
FQuiet: boolean; FQuiet: boolean;
FResolveMacros: boolean; FResolveMacros: boolean;
FParsers: TStrings; FParserNames: TStrings;
FShowConsole: boolean; FShowConsole: boolean;
fTitle: string; fTitle: string;
fWorkingDirectory: string; fWorkingDirectory: string;
procedure SetEnvironmentOverrides(AValue: TStringList); procedure SetEnvironmentOverrides(AValue: TStringList);
procedure SetParsers(AValue: TStrings); procedure SetParserNames(AValue: TStrings);
public public
constructor Create; constructor Create;
destructor Destroy; override; destructor Destroy; override;
@ -701,8 +701,7 @@ type
property CmdLineParams: string read fCmdLineParams write fCmdLineParams; property CmdLineParams: string read fCmdLineParams write fCmdLineParams;
property WorkingDirectory: string read fWorkingDirectory write fWorkingDirectory; property WorkingDirectory: string read fWorkingDirectory write fWorkingDirectory;
property EnvironmentOverrides: TStringList read FEnvironmentOverrides write SetEnvironmentOverrides; property EnvironmentOverrides: TStringList read FEnvironmentOverrides write SetEnvironmentOverrides;
property Scanners: TStrings read FParsers; deprecated 'use Parsers'; property Parsers: TStrings read FParserNames write SetParserNames;
property Parsers: TStrings read FParsers write SetParsers;
property ShowConsole: boolean read FShowConsole write FShowConsole default false; // sets poNoConsole/poNewConsole, works only on MSWindows property ShowConsole: boolean read FShowConsole write FShowConsole default false; // sets poNoConsole/poNewConsole, works only on MSWindows
property HideWindow: boolean read FHideWindow write FHideWindow default true; // sets/unsets swoHide/swoShow, works only on MSWindows property HideWindow: boolean read FHideWindow write FHideWindow default true; // sets/unsets swoHide/swoShow, works only on MSWindows
property ResolveMacros: boolean read FResolveMacros write FResolveMacros default true; property ResolveMacros: boolean read FResolveMacros write FResolveMacros default true;
@ -819,24 +818,24 @@ begin
FEnvironmentOverrides.Assign(AValue); FEnvironmentOverrides.Assign(AValue);
end; end;
procedure TIDEExternalToolOptions.SetParsers(AValue: TStrings); procedure TIDEExternalToolOptions.SetParserNames(AValue: TStrings);
begin begin
if FParsers.Equals(AValue) then Exit; if FParserNames.Equals(AValue) then Exit;
FParsers.Assign(AValue); FParserNames.Assign(AValue);
end; end;
constructor TIDEExternalToolOptions.Create; constructor TIDEExternalToolOptions.Create;
begin begin
ResolveMacros:=true; ResolveMacros:=true;
FEnvironmentOverrides:=TStringList.Create; FEnvironmentOverrides:=TStringList.Create;
FParsers:=TStringList.Create; FParserNames:=TStringList.Create;
FHideWindow:=true; FHideWindow:=true;
end; end;
destructor TIDEExternalToolOptions.Destroy; destructor TIDEExternalToolOptions.Destroy;
begin begin
FreeAndNil(FEnvironmentOverrides); FreeAndNil(FEnvironmentOverrides);
FreeAndNil(FParsers); FreeAndNil(FParserNames);
inherited Destroy; inherited Destroy;
end; end;
@ -886,7 +885,7 @@ begin
FShowConsole:=false; FShowConsole:=false;
FHideWindow:=true; FHideWindow:=true;
FResolveMacros:=true; FResolveMacros:=true;
FParsers.Clear; FParserNames.Clear;
fTitle:=''; fTitle:='';
fWorkingDirectory:=''; fWorkingDirectory:='';
FQuiet:=false; FQuiet:=false;

View File

@ -28,6 +28,8 @@ uses
// LCL // LCL
LCLType, LCLProc, Forms, Controls, Dialogs, ExtCtrls, StdCtrls, LCLType, LCLProc, Forms, Controls, Dialogs, ExtCtrls, StdCtrls,
Graphics, Menus, ComCtrls, DBActns, StdActns, ActnList, ImgList, Graphics, Menus, ComCtrls, DBActns, StdActns, ActnList, ImgList,
// LazUtils
LazLoggerBase, LazUTF8,
// IDEIntf // IDEIntf
ObjInspStrConsts, ComponentEditors, PropEdits, PropEditUtils, IDEWindowIntf, ObjInspStrConsts, ComponentEditors, PropEdits, PropEditUtils, IDEWindowIntf,
IDEImagesIntf; IDEImagesIntf;
@ -1334,17 +1336,17 @@ end;
procedure TActionCategoryProperty.GetValues(Proc: TGetStrProc); procedure TActionCategoryProperty.GetValues(Proc: TGetStrProc);
var var
I: Integer; I: Integer;
Values: TStringList; Values: TStringListUTF8Fast;
Act:TContainedAction; Act: TContainedAction;
ActLst:TCustomActionList; ActLst: TCustomActionList;
S:string; S: string;
begin begin
ActLst:=nil; ActLst:=nil;
Act:=GetComponent(0) as TContainedAction; Act:=GetComponent(0) as TContainedAction;
if Assigned(Act) then if Assigned(Act) then
ActLst:=Act.ActionList; ActLst:=Act.ActionList;
if not Assigned(ActLst) then exit; if not Assigned(ActLst) then exit;
Values := TStringList.Create; Values := TStringListUTF8Fast.Create;
try try
for i:=0 to ActLst.ActionCount-1 do for i:=0 to ActLst.ActionCount-1 do
begin begin

View File

@ -5,7 +5,9 @@ unit bufdatasetdsgn;
interface interface
uses uses
Classes, SysUtils, DB, bufdataset, ComponentEditors, FieldsEditor, ObjInspStrConsts; Classes, SysUtils, DB, bufdataset,
LazUTF8,
ComponentEditors, FieldsEditor, ObjInspStrConsts;
Type Type
@ -113,7 +115,7 @@ begin
if not Assigned(Designer.PropertyEditorHook) then if not Assigned(Designer.PropertyEditorHook) then
exit; exit;
FreeAndNil(FDatasetNames); // Free previous instance if any FreeAndNil(FDatasetNames); // Free previous instance if any
FDatasetNames:=TStringList.Create; FDatasetNames:=TStringListUTF8Fast.Create;
Designer.PropertyEditorHook.GetComponentNames(GetTypeData(TypeInfo(TDataset)),@GetDatasetNames); Designer.PropertyEditorHook.GetComponentNames(GetTypeData(TypeInfo(TDataset)),@GetDatasetNames);
Idx:=FDatasetNames.IndexOf(aBufDS.Name); Idx:=FDatasetNames.IndexOf(aBufDS.Name);
if Idx<>-1 then if Idx<>-1 then

View File

@ -231,6 +231,7 @@ var
begin begin
ControlsCount := 0; ControlsCount := 0;
CurParentNameList := TStringList.Create; CurParentNameList := TStringList.Create;
CurParentNameList.UseLocale := False;
for i:=0 to ASelection.Count-1 do for i:=0 to ASelection.Count-1 do
if ASelection.Items[i] is TControl then if ASelection.Items[i] is TControl then

View File

@ -28,7 +28,7 @@ uses
// LCL // LCL
Controls, Controls,
// LazUtils // LazUtils
LazUtilities, LazLoggerBase, Laz2_XMLCfg, LazMethodList; LazUtilities, LazLoggerBase, Laz2_XMLCfg, LazMethodList, LazUTF8;
type type
TComponentPriorityCategory = ( TComponentPriorityCategory = (
@ -228,7 +228,7 @@ type
fOrigComponentPageCache: TStringList; // Original fOrigComponentPageCache: TStringList; // Original
fUserComponentPageCache: TStringList; // User ordered fUserComponentPageCache: TStringList; // User ordered
// Used to find names that differ in character case only. // Used to find names that differ in character case only.
fOrigPageHelper: TStringList; fOrigPageHelper: TStringListUTF8Fast;
fHandlers: array[TComponentPaletteHandlerType] of TMethodList; fHandlers: array[TComponentPaletteHandlerType] of TMethodList;
fComponentPageClass: TBaseComponentPageClass; fComponentPageClass: TBaseComponentPageClass;
fSelected: TRegisteredComponent; fSelected: TRegisteredComponent;
@ -426,9 +426,9 @@ end;
constructor TCompPaletteOptions.Create; constructor TCompPaletteOptions.Create;
begin begin
inherited Create; inherited Create;
FPageNamesCompNames := TStringList.Create; FPageNamesCompNames := TStringListUTF8Fast.Create;
FPageNamesCompNames.OwnsObjects := True; FPageNamesCompNames.OwnsObjects := True;
FHiddenPageNames := TStringList.Create; FHiddenPageNames := TStringListUTF8Fast.Create;
FVisible := True; FVisible := True;
end; end;
@ -475,9 +475,9 @@ end;
function TCompPaletteOptions.IsDefault: Boolean; function TCompPaletteOptions.IsDefault: Boolean;
begin begin
Result := (PageNames.Count = 0) Result := (FPageNames.Count = 0)
and (FPageNamesCompNames.Count = 0) and (FPageNamesCompNames.Count = 0)
and (HiddenPageNames.Count = 0); and (FHiddenPageNames.Count = 0);
end; end;
procedure TCompPaletteOptions.Load(XMLConfig: TXMLConfig; Path: String); procedure TCompPaletteOptions.Load(XMLConfig: TXMLConfig; Path: String);
@ -600,7 +600,7 @@ constructor TCompPaletteUserOrder.Create(aPalette: TBaseComponentPalette);
begin begin
inherited Create; inherited Create;
fPalette:=aPalette; fPalette:=aPalette;
FComponentPages := TStringList.Create; FComponentPages := TStringListUTF8Fast.Create;
FComponentPages.OwnsObjects := True; FComponentPages.OwnsObjects := True;
end; end;
@ -679,13 +679,13 @@ begin
Clear; Clear;
fPalette.CacheOrigComponentPages; fPalette.CacheOrigComponentPages;
// First add user defined page order from EnvironmentOptions, // First add user defined page order from EnvironmentOptions,
FComponentPages.Assign(fOptions.PageNames); FComponentPages.Assign(fOptions.FPageNames);
// then add other pages which don't have user configuration // then add other pages which don't have user configuration
for PageI := 0 to fPalette.OrigPagePriorities.Count-1 do for PageI := 0 to fPalette.OrigPagePriorities.Count-1 do
begin begin
PgName:=fPalette.OrigPagePriorities.Keys[PageI]; PgName:=fPalette.OrigPagePriorities.Keys[PageI];
if (FComponentPages.IndexOf(PgName) = -1) if (FComponentPages.IndexOf(PgName) = -1)
and (fOptions.HiddenPageNames.IndexOf(PgName) = -1) then and (fOptions.FHiddenPageNames.IndexOf(PgName) = -1) then
FComponentPages.Add(PgName); FComponentPages.Add(PgName);
end; end;
// Map components with their pages // Map components with their pages
@ -802,13 +802,15 @@ begin
fComponentCache:=TAVLTree.Create(@CompareIDEComponentByClass); fComponentCache:=TAVLTree.Create(@CompareIDEComponentByClass);
fOrigComponentPageCache:=TStringList.Create; fOrigComponentPageCache:=TStringList.Create;
fOrigComponentPageCache.OwnsObjects:=True; fOrigComponentPageCache.OwnsObjects:=True;
fOrigComponentPageCache.UseLocale:=False;
fOrigComponentPageCache.CaseSensitive:=True; fOrigComponentPageCache.CaseSensitive:=True;
fOrigComponentPageCache.Sorted:=True; fOrigComponentPageCache.Sorted:=True;
fUserComponentPageCache:=TStringList.Create; fUserComponentPageCache:=TStringList.Create;
fUserComponentPageCache.OwnsObjects:=True; fUserComponentPageCache.OwnsObjects:=True;
fUserComponentPageCache.UseLocale:=False;
fUserComponentPageCache.CaseSensitive:=True; fUserComponentPageCache.CaseSensitive:=True;
fUserComponentPageCache.Sorted:=True; fUserComponentPageCache.Sorted:=True;
fOrigPageHelper:=TStringList.Create; // Note: CaseSensitive = False fOrigPageHelper:=TStringListUTF8Fast.Create; // Note: CaseSensitive = False
fOrigPageHelper.Sorted:=True; fOrigPageHelper.Sorted:=True;
fLastFoundCompClassName:=''; fLastFoundCompClassName:='';
fLastFoundRegComp:=Nil; fLastFoundRegComp:=Nil;

View File

@ -141,6 +141,7 @@ var
begin begin
//debugln('TSelectPropertiesForm.SetSelectedProps'); //debugln('TSelectPropertiesForm.SetSelectedProps');
L:=TStringList.Create; L:=TStringList.Create;
L.UseLocale:=False;
Try Try
L.Delimiter:=';'; L.Delimiter:=';';
L.DelimitedText:=AValue; L.DelimitedText:=AValue;

View File

@ -458,7 +458,7 @@ type
TIDEWindowsGlobalOptions = class TIDEWindowsGlobalOptions = class
private private
FList: TStringList; FOptList: TStringListUTF8Fast;
public public
constructor Create; constructor Create;
destructor Destroy; override; destructor Destroy; override;
@ -568,22 +568,21 @@ procedure TIDEWindowsGlobalOptions.Add(const aFormIDPrefix: string;
var var
xIndex: Integer; xIndex: Integer;
begin begin
xIndex := FList.Add(aFormIDPrefix); xIndex := FOptList.Add(aFormIDPrefix);
if FList.Objects[xIndex] = nil then if FOptList.Objects[xIndex] = nil then
FList.Objects[xIndex] := TIDEWindowGlobalOption.Create; FOptList.Objects[xIndex] := TIDEWindowGlobalOption.Create;
TIDEWindowGlobalOption(FList.Objects[xIndex]).CanSetVisibility := CanSetVisibility; TIDEWindowGlobalOption(FOptList.Objects[xIndex]).CanSetVisibility := CanSetVisibility;
end; end;
function TIDEWindowsGlobalOptions.CanSetVisibility(const aFormID: string function TIDEWindowsGlobalOptions.CanSetVisibility(const aFormID: string): Boolean;
): Boolean;
var var
I: Integer; I: Integer;
begin begin
for I := 0 to FList.Count-1 do for I := 0 to FOptList.Count-1 do
if Copy(aFormID, 1, Length(FList[I])) = FList[I] then if Copy(aFormID, 1, Length(FOptList[I])) = FOptList[I] then
begin begin
Result := TIDEWindowGlobalOption(FList.Objects[I]).CanSetVisibility; Result := TIDEWindowGlobalOption(FOptList.Objects[I]).CanSetVisibility;
Exit; Exit;
end; end;
Result := True;//default is true Result := True;//default is true
@ -593,14 +592,14 @@ constructor TIDEWindowsGlobalOptions.Create;
begin begin
inherited Create; inherited Create;
FList := TStringList.Create; FOptList := TStringListUTF8Fast.Create;
FList.Sorted := True; FOptList.Sorted := True;
FList.OwnsObjects := True; FOptList.OwnsObjects := True;
end; end;
destructor TIDEWindowsGlobalOptions.Destroy; destructor TIDEWindowsGlobalOptions.Destroy;
begin begin
FList.Free; FOptList.Free;
inherited Destroy; inherited Destroy;
end; end;

View File

@ -38,7 +38,7 @@ uses
{$IFnDEF UseOINormalCheckBox} CheckBoxThemed, {$ENDIF} {$IFnDEF UseOINormalCheckBox} CheckBoxThemed, {$ENDIF}
TreeFilterEdit, ListFilterEdit, TreeFilterEdit, ListFilterEdit,
// LazUtils // LazUtils
GraphType, LazConfigStorage, LazLoggerBase, GraphType, LazConfigStorage, LazLoggerBase, LazUTF8,
// IdeIntf // IdeIntf
IDEImagesIntf, IDEHelpIntf, ObjInspStrConsts, IDEImagesIntf, IDEHelpIntf, ObjInspStrConsts,
PropEdits, PropEditUtils, ComponentTreeView, OIFavoriteProperties, PropEdits, PropEditUtils, ComponentTreeView, OIFavoriteProperties,
@ -297,7 +297,7 @@ type
FItemIndex: integer; FItemIndex: integer;
FNameFont, FDefaultValueFont, FValueFont, FHighlightFont: TFont; FNameFont, FDefaultValueFont, FValueFont, FHighlightFont: TFont;
FValueDifferBackgrndColor: TColor; FValueDifferBackgrndColor: TColor;
FNewComboBoxItems: TStringList; FNewComboBoxItems: TStringListUTF8Fast;
FOnModified: TNotifyEvent; FOnModified: TNotifyEvent;
FRows: TFPList;// list of TOIPropertyGridRow FRows: TFPList;// list of TOIPropertyGridRow
FSelection: TPersistentSelectionList; FSelection: TPersistentSelectionList;
@ -2031,7 +2031,7 @@ end;
procedure TOICustomPropertyGrid.AddStringToComboBox(const s: string); procedure TOICustomPropertyGrid.AddStringToComboBox(const s: string);
begin begin
if FNewComboBoxItems=nil then if FNewComboBoxItems=nil then
FNewComboBoxItems:=TStringList.Create; FNewComboBoxItems:=TStringListUTF8Fast.Create;
FNewComboBoxItems.Add(s); FNewComboBoxItems.Add(s);
end; end;

View File

@ -2735,6 +2735,7 @@ var
begin begin
if not AutoFill then Exit; if not AutoFill then Exit;
Values:=TStringList.Create; Values:=TStringList.Create;
Values.UseLocale := False;
Values.Sorted:=paSortList in GetAttributes; Values.Sorted:=paSortList in GetAttributes;
try try
AddValue := @Values.Add; AddValue := @Values.Add;

View File

@ -92,7 +92,7 @@ type
FAccessClass: string; FAccessClass: string;
FAncestor: TPersistent; FAncestor: TPersistent;
FAncestorPos: Integer; FAncestorPos: Integer;
FAncestors: TStringList; FAncestors: TStringListUTF8Fast;
FAssignOp: String; FAssignOp: String;
FCurIndent: integer; FCurIndent: integer;
FCurrentPos: Integer; FCurrentPos: Integer;
@ -499,7 +499,7 @@ procedure TCompWriterPas.WriteChildren(Component: TComponent;
Step: TCWPChildrenStep); Step: TCWPChildrenStep);
var var
SRoot, SRootA, SParent: TComponent; SRoot, SRootA, SParent: TComponent;
SList: TStringList; SList: TStringListUTF8Fast;
SPos, i, SAncestorPos: Integer; SPos, i, SAncestorPos: Integer;
begin begin
// Write children list. // Write children list.
@ -520,7 +520,7 @@ begin
FRoot:=Component; FRoot:=Component;
if (FAncestor is TComponent) then if (FAncestor is TComponent) then
begin begin
FAncestors:=TStringList.Create; FAncestors:=TStringListUTF8Fast.Create;
if csInline in TComponent(FAncestor).ComponentState then if csInline in TComponent(FAncestor).ComponentState then
FRootAncestor := TComponent(FAncestor); FRootAncestor := TComponent(FAncestor);
TAccessComp(FAncestor).GetChildren(@AddToAncestorList,FRootAncestor); TAccessComp(FAncestor).GetChildren(@AddToAncestorList,FRootAncestor);
@ -1444,7 +1444,7 @@ begin
FMaxColumn:=CSPDefaultMaxColumn; FMaxColumn:=CSPDefaultMaxColumn;
FExecCustomProc:=CSPDefaultExecCustomProc; FExecCustomProc:=CSPDefaultExecCustomProc;
FExecCustomProcUnit:=CSPDefaultExecCustomProcUnit; FExecCustomProcUnit:=CSPDefaultExecCustomProcUnit;
FNeededUnits:=TStringList.Create; FNeededUnits:=TStringListUTF8Fast.Create;
FAccessClass:=CSPDefaultAccessClass; FAccessClass:=CSPDefaultAccessClass;
C:=TAccessComp.Create(nil); C:=TAccessComp.Create(nil);
FDefaultDefineProperties:=TMethod(@C.DefineProperties).Code; FDefaultDefineProperties:=TMethod(@C.DefineProperties).Code;

View File

@ -15,7 +15,7 @@ interface
uses uses
Classes, SysUtils, Classes, SysUtils,
// LazUtils // LazUtils
LazLoggerBase, LazSysUtils; LazLoggerBase, LazSysUtils, LazUTF8;
type type
@ -75,8 +75,8 @@ function DbgsTimeUsed(AFormat: String; AName: String): string;
implementation implementation
var var
NamedMemWatches: TStringList = nil; NamedMemWatches: TStringListUTF8Fast = nil;
NamedTimer: TStringList = nil; NamedTimer: TStringListUTF8Fast = nil;
NamedMemWatchesData: Array of record Sum, Last: Int64; end; NamedMemWatchesData: Array of record Sum, Last: Int64; end;
NamedTimerData: array of record Sum, Last: QWord; end; NamedTimerData: array of record Sum, Last: QWord; end;
@ -144,7 +144,7 @@ var
idx: Integer; idx: Integer;
begin begin
if NamedTimer = nil then begin if NamedTimer = nil then begin
NamedTimer := TStringList.Create; NamedTimer := TStringListUTF8Fast.Create;
NamedTimer.Sorted := True; NamedTimer.Sorted := True;
NamedTimer.Duplicates := dupError; NamedTimer.Duplicates := dupError;
end; end;
@ -180,7 +180,7 @@ var
idx: Integer; idx: Integer;
begin begin
if NamedMemWatches = nil then begin if NamedMemWatches = nil then begin
NamedMemWatches := TStringList.Create; NamedMemWatches := TStringListUTF8Fast.Create;
NamedMemWatches.Sorted := True; NamedMemWatches.Sorted := True;
NamedMemWatches.Duplicates := dupError; NamedMemWatches.Duplicates := dupError;
end; end;