Codetools, Debugger: Use a faster compare method for case-insensitive strings and StringLists.

git-svn-id: trunk@64465 -
This commit is contained in:
juha 2021-02-05 11:28:11 +00:00
parent e6d96156ec
commit 0feb7a5662
19 changed files with 107 additions and 85 deletions

View File

@ -1574,7 +1574,8 @@ constructor TFindIdentifierInUsesSection_FindMissingFPCUnit.Create;
begin
inherited;
FResults := TStringList.Create;
FResults.CaseSensitive := True;
FResults.CaseSensitive := True; // Why CaseSensitive?
FResults.UseLocale := False;
FResults.Duplicates := dupIgnore;
FResults.Sorted := True;
end;

View File

@ -34,10 +34,12 @@ uses
// LCL
LCLProc, FileUtil, Forms, Controls, Dialogs, ButtonPanel, Grids, StdCtrls,
ExtCtrls, ComCtrls,
AvgLvlTree,
// LazUtils
AvgLvlTree, LazUTF8,
// BuildIntf
ProjectIntf, PackageIntf,
// IDEIntf
ProjectIntf, LazIDEIntf, IDEDialogs, IDEWindowIntf,
PackageIntf,
LazIDEIntf, IDEDialogs, IDEWindowIntf,
// codetools
BasicCodeTools, FileProcs, LazFileUtils, LazFileCache, CodyStrConsts,
CodeToolManager, CodeCache, PPUParser, PPUCodeTools, DefineTemplates,
@ -217,7 +219,7 @@ end;
constructor TPPUDlgLinkedFile.Create;
begin
inherited Create;
Units:=TStringList.Create;
Units:=TStringListUTF8Fast.Create;
end;
destructor TPPUDlgLinkedFile.Destroy;

View File

@ -35,7 +35,7 @@ uses
dynlibs,
{$ENDIF}
// LazUtils
LazStringUtils,
LazStringUtils, LazUTF8,
// Codetools
PPUParser, CodeTree, FileProcs, LazFileUtils, BasicCodeTools, CodeGraph,
CodeToolManager, CodeToolsStructs;
@ -244,7 +244,7 @@ procedure TPPUMember.GetMissingUnits(var List: TStrings);
CurUnitName:=UsesList[i];
if Group.Groups.FindMemberWithUnitName(CurUnitName)=nil then begin
if List=nil then
List:=TStringList.Create;
List:=TStringListUTF8Fast.Create;
if List.IndexOf(CurUnitName)<0 then
List.Add(CurUnitName);
end;
@ -817,7 +817,7 @@ var
List: TStringList;
begin
AVLNode:=FMembers.FindLowest;
List:=TStringList.Create;
List:=TStringListUTF8Fast.Create;
while AVLNode<>nil do begin
Member:=TPPUMember(AVLNode.Data);
if not (pmfAutoDisabled in Member.Flags) then begin

View File

@ -34,7 +34,9 @@ unit PPUParser;
interface
uses
Classes, SysUtils, contnrs, FileProcs, LazFileUtils;
Classes, SysUtils, contnrs,
FileProcs,
LazFileUtils, LazUTF8;
const
PPUIsEndianBig = {$IFDEF ENDIAN_BIG}True{$ELSE}False{$ENDIF};
@ -2544,7 +2546,7 @@ begin
while not EndOfEntry do begin
AUnitName:=ReadEntryShortstring;
if List=nil then
List:=TStringList.Create;
List:=TStringListUTF8Fast.Create;
if List.IndexOf(AUnitName)<0 then
List.Add(AUnitName);
ReadEntryDWord; // CRC

View File

@ -57,7 +57,7 @@ uses
ExprEval, KeywordFuncLists, BasicCodeTools, LinkScanner,
CodeCache, LFMTrees, SourceChanger, CustomCodeTool, CodeToolsStructs,
// LazUtils
LazFileUtils, LazFileCache, AvgLvlTree;
LazFileUtils, LazFileCache, LazUTF8, AvgLvlTree;
type
TStandardCodeTool = class;
@ -1424,12 +1424,12 @@ begin
BuildTree(lsrMainUsesSectionEnd);
UsesNode:=FindMainUsesNode(UseContainsSection);
if UsesNode=nil then exit;
FoundInUnits:=TStringList.Create;
MissingInUnits:=TStringList.Create;
FoundInUnits:=TStringListUTF8Fast.Create;
MissingInUnits:=TStringListUTF8Fast.Create;
if IgnoreNormalUnits then
NormalUnits:=nil
else
NormalUnits:=TStringList.Create;
NormalUnits:=TStringListUTF8Fast.Create;
Node:=UsesNode.FirstChild;
while Node<>nil do begin
// read next unit name
@ -6656,7 +6656,7 @@ var
begin
if Found then begin
if FoundIncludeFiles=nil then
FoundIncludeFiles:=TStringList.Create;
FoundIncludeFiles:=TStringListUTF8Fast.Create;
NewFilename:=TrimFilename(AFilename);
if FoundIncludeFiles.IndexOf(NewFilename)<0 then
FoundIncludeFiles.Add(NewFilename);

View File

@ -48,7 +48,7 @@ uses
// LCL
LCLProc,
// LazUtils
LazClasses, LazLoggerBase, LazFileUtils, LazStringUtils, Maps, LazMethodList,
LazClasses, LazLoggerBase, LazFileUtils, LazStringUtils, Maps, LazMethodList, LazUTF8,
// DebuggerIntf
DbgIntfBaseTypes, DbgIntfMiscClasses, DbgIntfPseudoTerminal, DbgIntfCommonStrings;
@ -6069,12 +6069,12 @@ procedure TDebuggerIntf.EnvironmentChanged(Sender: TObject);
var
n, idx: integer;
S: String;
Env: TStringList;
Env: TStringListUTF8Fast;
begin
// Createe local copy
if FState <> dsNone then
begin
Env := TStringList.Create;
Env := TStringListUTF8Fast.Create;
try
Env.Assign(Environment);
@ -6231,7 +6231,7 @@ var
idx: Integer;
begin
if MDebuggerPropertiesList = nil
then MDebuggerPropertiesList := TStringList.Create;
then MDebuggerPropertiesList := TStringListUTF8Fast.Create;
idx := MDebuggerPropertiesList.IndexOf(ClassName);
if idx = -1
then begin
@ -6535,7 +6535,7 @@ constructor TBaseDebugManagerIntf.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FValueFormatterList := TStringList.Create;
FValueFormatterList := TStringListUTF8Fast.Create;
FValueFormatterList.Sorted := True;
FValueFormatterList.Duplicates := dupError;
end;
@ -6629,7 +6629,7 @@ initialization
DBG_DATA_MONITORS := DebugLogger.FindOrRegisterLogGroup('DBG_DATA_MONITORS' {$IFDEF DBG_DATA_MONITORS} , True {$ENDIF} );
DBG_DISASSEMBLER := DebugLogger.FindOrRegisterLogGroup('DBG_DISASSEMBLER' {$IFDEF DBG_DISASSEMBLER} , True {$ENDIF} );
MDebuggerClasses := TStringList.Create;
MDebuggerClasses := TStringListUTF8Fast.Create;
MDebuggerClasses.Sorted := True;
MDebuggerClasses.Duplicates := dupError;

View File

@ -15,7 +15,7 @@ uses
sockets,
syncobjs,
FpDbgClasses,
lazfglhash,
LazFglHash,
lazCollections,
fpjson,
fgl,

View File

@ -15,7 +15,7 @@ uses
DbgIntfDebuggerBase,
lazCollections,
syncobjs,
lazfglhash,
LazFglHash,
fpjson,
FpDbgClasses;

View File

@ -41,9 +41,11 @@ unit FpDbgDwarfDataClasses;
interface
uses
Classes, Types, SysUtils, FpDbgUtil, FpDbgInfo, FpDbgDwarfConst, Maps, Math,
FpDbgLoader, FpImgReaderBase, FpdMemoryTools, FpErrorMessages, LazLoggerBase,
LazClasses, LazFileUtils, LazUTF8, contnrs, DbgIntfBaseTypes;
Classes, Types, SysUtils, contnrs, Math,
Maps, LazClasses, LazFileUtils, LazLoggerBase, LazUTF8,
// FpDebug
FpDbgUtil, FpDbgInfo, FpDbgDwarfConst,
FpDbgLoader, FpImgReaderBase, FpdMemoryTools, FpErrorMessages, DbgIntfBaseTypes;
type
TDwarfSection = (dsAbbrev, dsARanges, dsFrame, dsInfo, dsLine, dsLoc, dsMacinfo, dsPubNames, dsPubTypes, dsRanges, dsStr);
@ -606,7 +608,7 @@ type
end;
{$IFDEF DwarfTestAccess} private {$ENDIF}
FLineNumberMap: TStringList;
FLineNumberMap: TStringListUTF8Fast;
FAddressMap: TMap; // Holds a key for each DW_TAG_subprogram / TFpSymbolDwarfDataProc, stores TDwarfAddressInfo
FAddressMapBuild: Boolean;
@ -4243,7 +4245,7 @@ begin
// use internally 64 bit target pointer
FAddressMap := TMap.Create(itu8, SizeOf(TDwarfAddressInfo));
FLineNumberMap := TStringList.Create;
FLineNumberMap := TStringListUTF8Fast.Create;
FLineNumberMap.Sorted := True;
FLineNumberMap.Duplicates := dupError;
@ -4342,9 +4344,10 @@ begin
end;
function TDwarfCompilationUnit.GetLineAddressMap(const AFileName: String): PDWarfLineMap;
function FindIndex: Integer;
var
Name: String;
function FindIndex: Integer;
begin
// try fullname first
Result := FLineNumberMap.IndexOf(AFileName);
@ -4354,14 +4357,12 @@ function TDwarfCompilationUnit.GetLineAddressMap(const AFileName: String): PDWar
Result := FLineNumberMap.IndexOf(Name);
if Result <> -1 then Exit;
Name := UpperCase(Name);
for Result := 0 to FLineNumberMap.Count - 1 do
begin
if Name = UpperCase(ExtractFileName(FLineNumberMap[Result]))
then Exit;
end;
Result := -1
if UTF8CompareLatinTextFast(Name, ExtractFileName(FLineNumberMap[Result])) = 0 then
Exit;
Result := -1;
end;
var
idx: Integer;
begin

View File

@ -11,7 +11,7 @@ uses
{$ifdef windows}
Windows, // After LCLType
{$endif}
fgl, lazfglhash,
fgl, LazFglHash,
fpDbgSymTable,
Classes, SysUtils, DbgIntfBaseTypes, contnrs,
FpDbgCommon;

View File

@ -32,10 +32,10 @@ interface
uses
Classes, SysUtils,
FpImgReaderBase,
fpDbgSymTable, DbgIntfBaseTypes,
FpImgReaderElfTypes, LCLProc, // these files are part of
FpDbgCommon;
LazUTF8, LazLoggerBase,
DbgIntfBaseTypes,
// FpDebug
FpImgReaderBase, fpDbgSymTable, FpImgReaderElfTypes, FpDbgCommon;
type
TElfSection = packed record
@ -67,7 +67,7 @@ type
TElfDbgSource = class(TDbgImageReader) // executable parser
private
FSections: TStringList;
FSections: TStringListUTF8Fast;
FFileLoader : TDbgFileLoader;
fOwnSource : Boolean;
fElfFile : TElfFile;
@ -346,7 +346,7 @@ var
i: Integer;
fs: TElfSection;
begin
FSections := TStringList.Create;
FSections := TStringListUTF8Fast.Create;
FSections.Sorted := True;
//FSections.Duplicates := dupError;
FSections.CaseSensitive := False;

View File

@ -6,10 +6,10 @@ interface
uses
Classes, SysUtils, contnrs,
macho, FpImgReaderMachoFile, FpImgReaderBase, LazLoggerBase,
LazFglHash, LazLoggerBase, LazUTF8,
DbgIntfBaseTypes,
lazfglhash,
fpDbgSymTable, FpDbgUtil;
// FpDebug
macho, FpImgReaderMachoFile, FpImgReaderBase, fpDbgSymTable, FpDbgUtil;
type
@ -18,7 +18,7 @@ type
TDbgMachoDataSource = class(TDbgImageReader)
private
fSource : TDbgFileLoader;
FSections: TStringList;
FSections: TStringListUTF8Fast;
fSubFiles: TStringList;
fAddressMapList: TDbgAddressMapList;
fOwnSource : Boolean;
@ -407,7 +407,7 @@ begin
ReadFile;
FSections := TStringList.Create;
FSections := TStringListUTF8Fast.Create;
FSections.Sorted := True;
FSections.Duplicates := dupAccept;
FSections.CaseSensitive := False;

View File

@ -39,8 +39,10 @@ unit FpImgReaderWinPE;
interface
uses
Classes, {$ifdef windows}windows,{$endif} SysUtils, math, FpImgReaderBase, FpImgReaderWinPETypes,
LazLoggerBase, fpDbgSymTable, DbgIntfBaseTypes;
Classes, {$ifdef windows}windows,{$endif} SysUtils, math,
LazLoggerBase, LazUTF8,
DbgIntfBaseTypes,
FpImgReaderBase, FpImgReaderWinPETypes, fpDbgSymTable;
type
@ -48,7 +50,7 @@ type
TPEFileSource = class(TDbgImageReader)
private
FSections: TStringList;
FSections: TStringListUTF8Fast;
FFileLoader : TDbgFileLoader;
FOwnLoader : Boolean;
FCodeBase : DWord;
@ -100,7 +102,7 @@ end;
constructor TPEFileSource.Create(ASource: TDbgFileLoader; ADebugMap: TObject; OwnSource: Boolean);
begin
FSections := TStringList.Create;
FSections := TStringListUTF8Fast.Create;
FSections.Sorted := False; // need sections in original order / Symbols use "SectionNumber"
//FSections.Duplicates := dupError;
FSections.CaseSensitive := False;

View File

@ -916,7 +916,7 @@ type
FInIdle: Boolean;
FRunQueueOnUnlock: Boolean;
FDebuggerFlags: TGDBMIDebuggerFlags;
FSourceNames: TStringList; // Objects[] -> TMap[Integer|Integer] -> TDbgPtr
FSourceNames: TStringListUTF8Fast; // Objects[] -> TMap[Integer|Integer] -> TDbgPtr
FInProcessStopped: Boolean; // paused, but maybe state run
FCommandNoneMiState: Array [TGDBMIExecCommandType] of Boolean;
FCommandAsyncState: Array [TGDBMIExecCommandType] of Boolean;
@ -8135,10 +8135,12 @@ end;
constructor TGDBMILineInfo.Create(const ADebugger: TDebuggerIntf);
begin
FSourceIndex := TStringList.Create;
FSourceIndex.UseLocale := False;
FSourceIndex.Sorted := True;
FSourceIndex.Duplicates := dupError;
FSourceIndex.CaseSensitive := True;
FRequestedSources := TStringList.Create;
FRequestedSources.UseLocale := False;
FRequestedSources.Sorted := True;
FRequestedSources.Duplicates := dupError;
FRequestedSources.CaseSensitive := True;
@ -8436,7 +8438,7 @@ begin
FTargetInfo.TargetPID := 0;
FTargetInfo.TargetFlags := [];
FDebuggerFlags := [];
FSourceNames := TStringList.Create;
FSourceNames := TStringListUTF8Fast.Create;
FSourceNames.Sorted := True;
FSourceNames.Duplicates := dupError;
FSourceNames.CaseSensitive := False;

View File

@ -7,11 +7,15 @@ unit FpDebugDebugger;
interface
uses
Classes, SysUtils, fgl, math, Forms, Maps, process, LazLogger, LazClasses,
Dialogs, FpDbgClasses, FpDbgInfo, contnrs, FpErrorMessages, FpPascalBuilder,
DbgIntfBaseTypes, DbgIntfDebuggerBase, FpdMemoryTools, FpPascalParser,
FPDbgController, FpDbgDwarfDataClasses, FpDbgDwarfFreePascal, FpDbgDwarf,
FpDbgUtil, FpDebugDebuggerUtils;
Classes, SysUtils, fgl, math, contnrs, process,
Forms, Dialogs,
Maps, LazLogger, LazUTF8,
DbgIntfBaseTypes, DbgIntfDebuggerBase,
FpDebugDebuggerUtils,
// FpDebug
FpDbgClasses, FpDbgInfo, FpErrorMessages, FpPascalBuilder, FpdMemoryTools,
FpPascalParser, FPDbgController, FpDbgDwarfDataClasses, FpDbgDwarfFreePascal,
FpDbgDwarf, FpDbgUtil;
type
@ -603,7 +607,7 @@ type
TFpLineInfo = class(TDBGLineInfo) //class(TGDBMILineInfo)
private
FRequestedSources: TStringList;
FRequestedSources: TStringListUTF8Fast;
protected
function FpDebugger: TFpDebugDebugger;
procedure DoStateChange(const {%H-}AOldState: TDBGState); override;
@ -736,8 +740,7 @@ procedure Register;
implementation
uses
FpDbgDisasX86,
FpDbgCommon;
FpDbgDisasX86;
var
DBG_VERBOSE, DBG_WARNINGS, DBG_BREAKPOINTS, FPDBG_COMMANDS: PLazLoggerLogGroup;
@ -2847,7 +2850,7 @@ end;
constructor TFpLineInfo.Create(const ADebugger: TDebuggerIntf);
begin
FRequestedSources := TStringList.Create;
FRequestedSources := TStringListUTF8Fast.Create;
inherited Create(ADebugger);
end;

View File

@ -12,12 +12,15 @@ uses
{$IFdef WithWinMemReader}
windows,
{$ENDIF}
Classes, sysutils, math, FpdMemoryTools, FpDbgInfo, FpDbgClasses,
GDBMIDebugger, DbgIntfBaseTypes, DbgIntfDebuggerBase, GDBMIMiscClasses,
GDBTypeInfo, LCLProc, Forms, FpDbgLoader, FpDbgDwarf, LazLoggerBase,
LazLoggerProfiling, LazClasses, FpPascalParser, FpPascalBuilder,
FpErrorMessages, FpDbgDwarfDataClasses, FpDbgDwarfFreePascal, FpDbgCommon,
MenuIntf;
Classes, sysutils, math,
Forms,
LazUTF8, LazLoggerBase, LazClasses,
MenuIntf,
DbgIntfBaseTypes, DbgIntfDebuggerBase,
GDBMIDebugger, GDBMIMiscClasses, GDBTypeInfo,
// FpDebug
FpDbgInfo, FpDbgLoader, FpDbgDwarf, FpPascalParser, FpPascalBuilder,
FpdMemoryTools, FpErrorMessages, FpDbgDwarfDataClasses, FpDbgCommon;
type
@ -197,7 +200,7 @@ type
TFpGDBMILineInfo = class(TDBGLineInfo) //class(TGDBMILineInfo)
private
FRequestedSources: TStringList;
FRequestedSources: TStringListUTF8Fast;
protected
function FpDebugger: TFpGDBMIDebugger;
procedure DoStateChange(const {%H-}AOldState: TDBGState); override;
@ -665,7 +668,7 @@ end;
constructor TFpGDBMILineInfo.Create(const ADebugger: TDebuggerIntf);
begin
FRequestedSources := TStringList.Create;
FRequestedSources := TStringListUTF8Fast.Create;
inherited Create(ADebugger);
end;

View File

@ -25,11 +25,15 @@ uses
{$IFdef WithWinMemReader}
windows,
{$ENDIF}
Classes, sysutils, math, FpdMemoryTools, FpDbgInfo, LldbDebugger,
LldbInstructions, LldbHelper, DbgIntfBaseTypes, DbgIntfDebuggerBase, LCLProc,
Forms, FpDbgLoader, FpDbgDwarf, LazLoggerBase, LazClasses, FpPascalParser,
FpPascalBuilder, FpErrorMessages, FpDbgDwarfDataClasses, FpDbgDwarfFreePascal,
FpDbgCommon;
Classes, sysutils, math,
Forms,
LazLoggerBase, LazUTF8, LazClasses,
// DebuggerIntf
DbgIntfBaseTypes, DbgIntfDebuggerBase,
// FpDebug
FpdMemoryTools, FpDbgInfo, FpPascalParser, FpDbgLoader, FpDbgDwarf,
FpPascalBuilder, FpErrorMessages, FpDbgDwarfDataClasses, FpDbgCommon,
LldbDebugger, LldbInstructions, LldbHelper;
type
@ -251,7 +255,7 @@ type
TFpLldbLineInfo = class(TDBGLineInfo)
private
FRequestedSources: TStringList;
FRequestedSources: TStringListUTF8Fast;
protected
function FpDebugger: TFpLldbDebugger;
procedure DoStateChange(const {%H-}AOldState: TDBGState); override;
@ -891,7 +895,7 @@ end;
constructor TFpLldbLineInfo.Create(const ADebugger: TDebuggerIntf);
begin
FRequestedSources := TStringList.Create;
FRequestedSources := TStringListUTF8Fast.Create;
inherited Create(ADebugger);
end;

View File

@ -5,7 +5,10 @@ unit TestCommonSources;
interface
uses
Classes, SysUtils, LCLType, strutils, LazFileUtils, TestOutputLogger;
Classes, SysUtils, strutils,
LCLType,
LazFileUtils, LazUTF8,
TestOutputLogger;
{$R sources.rc}
@ -19,7 +22,7 @@ type
FFileName: String;
FFolder: String;
FOtherSources: Array of TCommonSource;
FBreakPoints: TStringList;
FBreakPoints: TStringListUTF8Fast;
function GetBreakPoints(AName: String): Integer;
function GetFullFileName: String;
function GetOtherBreakPoints(AUnitName, AName: String): Integer;
@ -43,7 +46,7 @@ function GetCommonSourceFor(AName: String): TCommonSource;
implementation
var
CommonSources: TStringList;
CommonSources: TStringListUTF8Fast;
BlockRecurseName: String;
function GetCommonSourceFor(AName: String): TCommonSource;
@ -82,7 +85,7 @@ begin
i := FBreakPoints.IndexOf(AName);
if (i < 0) or (FBreakPoints.Objects[i] = nil) then
raise Exception.Create('Break unknown '+AName);
Result := Integer(PtrInt(FBreakPoints.Objects[i]));
Result := PtrInt(FBreakPoints.Objects[i]);
//TestLogger.DebugLn(['Break: ',AName, ' ',Result]);
end;
@ -148,7 +151,7 @@ begin
FData.LoadFromStream(r);
r.Free;
FBreakPoints := TStringList.Create;
FBreakPoints := TStringListUTF8Fast.Create;
if FData.Count < 1 then exit;
// TEST_USES
@ -233,7 +236,7 @@ begin
end;
initialization
CommonSources := TStringList.Create;
CommonSources := TStringListUTF8Fast.Create;
finalization;
while CommonSources.Count > 0 do begin

View File

@ -280,8 +280,7 @@ begin
OutputStream.Free;
end;
function TCompilerProcess.CallCompiler(const ACommand, ACurDir: String
): Boolean;
function TCompilerProcess.CallCompiler(const ACommand, ACurDir: String): Boolean;
var
FpcBuild: TProcessUTF8;
OutputLines: TStrings;