mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-11-11 11:09:33 +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
|
type
|
||||||
TCodeCache = class;
|
TCodeCache = class;
|
||||||
|
|
||||||
|
{ TCodeBuffer }
|
||||||
|
|
||||||
TCodeBuffer = class(TSourceLog)
|
TCodeBuffer = class(TSourceLog)
|
||||||
private
|
private
|
||||||
FFilename: string;
|
FFilename: string;
|
||||||
@ -85,6 +87,7 @@ type
|
|||||||
procedure IncrementRefCount;
|
procedure IncrementRefCount;
|
||||||
procedure ReleaseRefCount;
|
procedure ReleaseRefCount;
|
||||||
procedure MakeFileDateValid;
|
procedure MakeFileDateValid;
|
||||||
|
function SourceIsText: boolean;
|
||||||
public
|
public
|
||||||
property CodeCache: TCodeCache read FCodeCache write FCodeCache;
|
property CodeCache: TCodeCache read FCodeCache write FCodeCache;
|
||||||
property Filename: string read FFilename write SetFilename;
|
property Filename: string read FFilename write SetFilename;
|
||||||
@ -853,6 +856,20 @@ begin
|
|||||||
FLoadDate:=FileAge(Filename);
|
FLoadDate:=FileAge(Filename);
|
||||||
end;
|
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;
|
function TCodeBuffer.FileDateOnDisk: longint;
|
||||||
begin
|
begin
|
||||||
Result:=FileAge(Filename);
|
Result:=FileAge(Filename);
|
||||||
|
|||||||
@ -133,6 +133,17 @@ var
|
|||||||
ACaption, AText: string;
|
ACaption, AText: string;
|
||||||
FileReadable: boolean;
|
FileReadable: boolean;
|
||||||
begin
|
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
|
repeat
|
||||||
FileReadable:=true;
|
FileReadable:=true;
|
||||||
if (lbfCheckIfText in Flags)
|
if (lbfCheckIfText in Flags)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user