mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-11-03 10:39:38 +01:00
LoadCodeBuffer now uses cache for virtual files
git-svn-id: trunk@8718 -
This commit is contained in:
parent
c89be56e6f
commit
fb3672a053
@ -44,6 +44,8 @@ uses
|
||||
type
|
||||
TCodeCache = class;
|
||||
|
||||
{ TCodeBuffer }
|
||||
|
||||
TCodeBuffer = class(TSourceLog)
|
||||
private
|
||||
FFilename: string;
|
||||
@ -85,6 +87,7 @@ type
|
||||
procedure IncrementRefCount;
|
||||
procedure ReleaseRefCount;
|
||||
procedure MakeFileDateValid;
|
||||
function SourceIsText: boolean;
|
||||
public
|
||||
property CodeCache: TCodeCache read FCodeCache write FCodeCache;
|
||||
property Filename: string read FFilename write SetFilename;
|
||||
@ -853,6 +856,20 @@ begin
|
||||
FLoadDate:=FileAge(Filename);
|
||||
end;
|
||||
|
||||
function TCodeBuffer.SourceIsText: boolean;
|
||||
var
|
||||
l: LongInt;
|
||||
i: Integer;
|
||||
s: String;
|
||||
begin
|
||||
l:=SourceLength;
|
||||
if l>1024 then l:=1024;
|
||||
s:=Source;
|
||||
for i:=1 to l do
|
||||
if s[i] in [#0..#8,#11..#12,#14..#31] then exit(false);
|
||||
Result:=true;
|
||||
end;
|
||||
|
||||
function TCodeBuffer.FileDateOnDisk: longint;
|
||||
begin
|
||||
Result:=FileAge(Filename);
|
||||
|
||||
@ -133,6 +133,17 @@ var
|
||||
ACaption, AText: string;
|
||||
FileReadable: boolean;
|
||||
begin
|
||||
if [lbfUpdateFromDisk,lbfRevert]*Flags=[] then begin
|
||||
// can use cache
|
||||
ACodeBuffer:=CodeToolBoss.LoadFile(AFilename,false,false);
|
||||
if ACodeBuffer<>nil then begin
|
||||
// file is in cache
|
||||
if (not (lbfCheckIfText in Flags)) or ACodeBuffer.SourceIsText then begin
|
||||
Result:=mrOk;
|
||||
exit;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
repeat
|
||||
FileReadable:=true;
|
||||
if (lbfCheckIfText in Flags)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user