mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-07 08:58:23 +02:00
ChmHelp, FpPkg, SynUni: Use a faster compare method for case-insensitive strings and StringLists.
git-svn-id: trunk@64455 -
This commit is contained in:
parent
d5db655e0e
commit
504af3561f
@ -6,8 +6,9 @@ interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils,
|
||||
Dialogs, FileUtil, LazFileUtils, LazUTF8,
|
||||
LazHelpIntf, HelpIntfs, IDEHelpIntf, MacroIntf;
|
||||
Dialogs, LazHelpIntf, HelpIntfs,
|
||||
FileUtil, LazFileUtils, LazUTF8,
|
||||
IDEHelpIntf, MacroIntf;
|
||||
|
||||
const
|
||||
sFPCLangRef = 'FPC Language Reference';
|
||||
@ -20,7 +21,7 @@ type
|
||||
private
|
||||
FCHMSearchPath: string;
|
||||
FKeywordNodes: TList;
|
||||
FKeyWordsList: TStringList;
|
||||
FKeyWordsList: TStringListUTF8Fast;
|
||||
FRTLIndex: TStringList;
|
||||
procedure ClearKeywordNodes;
|
||||
procedure LoadChmIndex(const Path, ChmFileName: string;
|
||||
@ -68,7 +69,7 @@ constructor TLangRefHelpDatabase.Create(TheOwner: TComponent);
|
||||
begin
|
||||
inherited Create(TheOwner);
|
||||
FKeywordNodes := TList.Create;
|
||||
FKeyWordsList := TStringList.Create;
|
||||
FKeyWordsList := TStringListUTF8Fast.Create;
|
||||
FKeyWordsList.CaseSensitive := False;
|
||||
FRTLIndex := TStringList.Create;
|
||||
FRTLIndex.CaseSensitive := False;
|
||||
|
@ -29,7 +29,7 @@ interface
|
||||
uses
|
||||
Classes, SysUtils,
|
||||
// LazUtils
|
||||
FileUtil, LazLogger, LazFileUtils, LazConfigStorage, UTF8Process,
|
||||
FileUtil, LazLogger, LazFileUtils, LazConfigStorage, UTF8Process, LazUTF8,
|
||||
// LCL
|
||||
Controls, Forms, Dialogs, LazHelpIntf, HelpIntfs, LCLPlatformDef, InterfaceBase,
|
||||
// IdeIntf
|
||||
@ -184,7 +184,7 @@ end;
|
||||
|
||||
procedure TChmHelpViewer.OpenAllCHMsInSearchPath(const SearchPath: String);
|
||||
var
|
||||
CHMFiles: TStringList;
|
||||
CHMFiles: TStringListUTF8Fast;
|
||||
SearchPaths: TStringList; // SearchPath split to a StringList
|
||||
SearchFiles: TStringList; // Files found in SearchPath
|
||||
i: integer;
|
||||
@ -214,10 +214,8 @@ begin
|
||||
}
|
||||
// Just open all CHM files in all directories+subdirs in ;-delimited searchpath:
|
||||
SearchPaths:=TStringList.Create;
|
||||
CHMFiles:=TStringList.Create;
|
||||
CHMFiles:=TStringListUTF8Fast.Create;
|
||||
try
|
||||
CHMFiles.Sorted:=true;
|
||||
CHMFiles.Duplicates:=dupIgnore;
|
||||
SearchPaths.Delimiter:=';';
|
||||
SearchPaths.StrictDelimiter:=false;
|
||||
SearchPaths.DelimitedText:=SearchPath;
|
||||
@ -231,6 +229,8 @@ begin
|
||||
CHMFiles.AddStrings(SearchFiles);
|
||||
SearchFiles.Free;
|
||||
end;
|
||||
CHMFiles.Sorted:=true;
|
||||
CHMFiles.Duplicates:=dupIgnore;
|
||||
{$IFDEF CHMLOADTIMES}
|
||||
DebugLn(['CHMLOADTIMES: ',Format('Searching files in %s took %d ms',[SearchPath,DateTimeToTimeStamp(Now-StartTime).Time])]);
|
||||
StartTime := Now;
|
||||
@ -239,7 +239,7 @@ begin
|
||||
fHelpConnection.BeginUpdate;
|
||||
for i := 0 to CHMFiles.Count-1 do
|
||||
begin
|
||||
if UpperCase(ExtractFileExt(CHMFiles[i]))='.CHM' then
|
||||
if CompareFileExtQuick(CHMFiles[i], 'chm') = 0 then
|
||||
begin
|
||||
fHelpConnection.OpenURL(CHMFiles[i], '/index.html');
|
||||
// This is probably no longer necessary as we're now waiting for the viewer's
|
||||
|
@ -8,6 +8,8 @@ uses
|
||||
Classes, SysUtils, contnrs,
|
||||
// LCL
|
||||
Forms,
|
||||
// LazUtils
|
||||
LazUTF8,
|
||||
// IdeIntf
|
||||
ProjectIntf, NewItemIntf, FormEditingIntf;
|
||||
|
||||
@ -156,16 +158,14 @@ Var
|
||||
D : TCustomFormDescr;
|
||||
|
||||
begin
|
||||
L:=TStringList.Create;
|
||||
L:=TStringListUTF8Fast.Create;
|
||||
Try
|
||||
L.Sorted:=True;
|
||||
L.Duplicates:=dupIgnore;
|
||||
For I:=0 to CustomFormList.Count-1 do
|
||||
L.Add(TCustomFormDescr(CustomFormList[i]).Category);
|
||||
For I:=0 to L.Count-1 do
|
||||
begin
|
||||
RegisterNewItemCategory(TNewIDEItemCategory.Create(L[i]));
|
||||
end;
|
||||
Finally
|
||||
L.Free;
|
||||
end;
|
||||
|
@ -14,6 +14,7 @@ uses
|
||||
ExtCtrls,
|
||||
Dialogs,
|
||||
ActnList, ComboEx,
|
||||
LazUTF8,
|
||||
PackageIntf,
|
||||
IDEOptEditorIntf,
|
||||
IDEOptionsIntf, SynEdit,
|
||||
@ -429,7 +430,7 @@ constructor TFppkgPackageOptionsFrm.Create(AOwner: TComponent);
|
||||
begin
|
||||
inherited Create(AOwner);
|
||||
FPackageVariantList := TFppkgPackageVariantList.Create(True);
|
||||
FPackageList := TStringList.Create;
|
||||
FPackageList := TStringListUTF8Fast.Create;
|
||||
TStringList(FPackageList).Sorted := True;
|
||||
TStringList(FPackageList).Duplicates := dupIgnore;
|
||||
end;
|
||||
|
@ -961,15 +961,21 @@ begin
|
||||
end;
|
||||
|
||||
procedure TSynUniDesigner.SortClick(Sender: TObject);
|
||||
var i:integer;
|
||||
var
|
||||
i: integer;
|
||||
s: String;
|
||||
begin
|
||||
With TStringList.Create do
|
||||
try
|
||||
for i:=0 to Memo.Lines.Count-1 do
|
||||
begin
|
||||
s := Trim(Memo.Lines[i]);
|
||||
if s<>'' then
|
||||
Add(s);
|
||||
end;
|
||||
Sorted:=true;
|
||||
Duplicates:=dupIgnore;
|
||||
for i:=0 to Memo.Lines.Count-1 do if trim(Memo.lines[i])<>'' then add(trim(Memo.lines[i]));
|
||||
sort;
|
||||
Memo.text:=trim(text);
|
||||
Memo.Text:=Trim(text);
|
||||
finally
|
||||
free;
|
||||
end;
|
||||
|
@ -555,8 +555,7 @@ end;
|
||||
|
||||
{ TSynSymbolGroup }
|
||||
|
||||
constructor TSynSymbolGroup.Create(s: string;
|
||||
attr: TSynHighlighterAttributes);
|
||||
constructor TSynSymbolGroup.Create(s: string; attr: TSynHighlighterAttributes);
|
||||
begin
|
||||
Attribs:=attr;
|
||||
KeywordsList:=TStringList.Create;
|
||||
@ -933,7 +932,7 @@ var
|
||||
CurTagIndex:Integer;
|
||||
LineNumber:integer;
|
||||
Param:string;
|
||||
xmlInfoTags:TStringList;
|
||||
xmlInfoTags: TStringList;
|
||||
|
||||
////TL Guess FPC doesn't support optional parameters. Never used this in Delphi or Kylix.
|
||||
////TL I'm going to remove them and explicitly state the parms in each call.
|
||||
@ -2699,11 +2698,11 @@ end;
|
||||
|
||||
procedure TSynUniSyn.LoadFromFile(FileName: string);
|
||||
var
|
||||
F: TFileStreamUTF8;
|
||||
F: TFileStream;
|
||||
begin
|
||||
if FileName = '' then
|
||||
raise exception.Create('FileName is empty');
|
||||
F:=TFileStreamUTF8.Create(FileName,fmOpenRead or fmShareDenyWrite);
|
||||
F:=TFileStream.Create(FileName,fmOpenRead or fmShareDenyWrite);
|
||||
try
|
||||
LoadFromStream( F );
|
||||
finally
|
||||
@ -2713,11 +2712,11 @@ end;
|
||||
|
||||
procedure TSynUniSyn.SaveToFile(FileName: string);
|
||||
var
|
||||
F: TFileStreamUTF8;
|
||||
F: TFileStream;
|
||||
begin
|
||||
if FileName = '' then
|
||||
raise exception.Create('FileName is empty');
|
||||
F:=TFileStreamUTF8.Create(FileName,fmOpenWrite or fmShareDenyNone);
|
||||
F:=TFileStream.Create(FileName,fmOpenWrite or fmShareDenyNone);
|
||||
try
|
||||
SaveToStream( F );
|
||||
finally
|
||||
|
Loading…
Reference in New Issue
Block a user