• R/O
  • SSH
  • HTTPS

dzlargetextview: Commit


Commit MetaInfo

Revision267 (tree)
Zeit2016-05-30 02:49:51
Autortwm

Log Message

pass the filename + '.LineIndex' to the TLineIndexes file so the index can be reused (requires writing permission in that directory for now)

Ändern Zusammenfassung

Diff

--- trunk/src/dzLargeTextViewer.dpr (revision 266)
+++ trunk/src/dzLargeTextViewer.dpr (revision 267)
@@ -4,7 +4,6 @@
44 Forms,
55 w_LargeTextViewer in 'w_LargeTextViewer.pas' {f_LargeTextViewer},
66 u_TextFileIndexer in 'u_TextFileIndexer.pas',
7- u_Int64List in 'u_Int64List.pas',
87 w_GotoLine in 'w_GotoLine.pas' {f_GotoLine},
98 w_Search in 'w_Search.pas' {f_Search},
109 JclUnicode in '..\libs\jcl\source\common\JclUnicode.pas',
--- trunk/src/dzLargeTextViewer.dproj (revision 266)
+++ trunk/src/dzLargeTextViewer.dproj (revision 267)
@@ -404,7 +404,6 @@
404404 <MainSource>MainSource</MainSource>
405405 </DelphiCompile>
406406 <DCCReference Include="..\libs\jcl\source\common\JclUnicode.pas" />
407- <DCCReference Include="u_Int64List.pas" />
408407 <DCCReference Include="u_Int64ListFile.pas" />
409408 <DCCReference Include="u_LargeTextAccess.pas" />
410409 <DCCReference Include="u_TextFileIndexer.pas" />
--- trunk/src/u_TextFileIndexer.pas (revision 266)
+++ trunk/src/u_TextFileIndexer.pas (revision 267)
@@ -5,7 +5,6 @@
55 uses
66 SysUtils,
77 Classes,
8- u_Int64List,
98 u_Int64ListFile,
109 u_dzCriticalSection,
1110 u_LargeTextAccess;
@@ -14,8 +13,11 @@
1413 TTextFileIndexer = class
1514 private
1615 type
17- TLineIndexes = TInt64ListFile;
18- private
16+ TLineIndexes = class(TInt64ListFile)
17+ private
18+ procedure InitCount;
19+ end;
20+ private
1921 FCritSect: TdzCriticalSection;
2022 FLineIndexes: TLineIndexes;
2123 FIsDone: boolean;
@@ -44,9 +46,9 @@
4446 constructor TTextFileIndexer.Create(const _Filename: string);
4547 begin
4648 inherited Create;
47- FLineIndexes := TLineIndexes.Create;
48-// FLineIndexes.Capacity := MaxListSize; // OneGibiByte div SizeOf(Int64);
4949 FFilename := _Filename;
50+ FLineIndexes := TLineIndexes.Create(FFilename + '.LineIndex');
51+ FLineIndexes.InitCount;
5052 FCritSect := TdzCriticalSection.Create;
5153 end;
5254
@@ -74,6 +76,10 @@
7476 lta: TLargeTextAccess;
7577 begin
7678 FAbortRequested := False;
79+ if FLineIndexes.Count > 0 then begin
80+ FIsDone := True;
81+ Exit;
82+ end;
7783 FIsDone := False;
7884 lta := TLargeTextAccess.Create(FFilename, ofForward);
7985 try
@@ -90,7 +96,7 @@
9096 finally
9197 FreeAndNil(lta);
9298 end;
93- FIsDone := true;
99+ FIsDone := True;
94100 end;
95101
96102 function TTextFileIndexer.GetLineIndex(_Idx: integer): Int64;
@@ -115,7 +121,25 @@
115121
116122 procedure TTextFileIndexer.Abort;
117123 begin
118- FAbortRequested := true;
124+ FAbortRequested := True;
119125 end;
120126
127+{ TTextFileIndexer.TLineIndexes }
128+
129+procedure TTextFileIndexer.TLineIndexes.InitCount;
130+var
131+ Size: Int64;
132+ Idx: Int64;
133+begin
134+ Size := FTempFile.Size;
135+ if (FCount = 0) and (Size > 0) and (Size mod SizeOf(FBuffer) = 0) then begin
136+ FCount := Size div SizeOf(FCount);
137+ Idx := FCount - 1;
138+ while Items[Idx] = 0 do begin
139+ Dec(Idx);
140+ end;
141+ FCount := Idx + 1;
142+ end;
143+end;
144+
121145 end.
Show on old repository browser