mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-07-29 23:25:56 +02:00
* load object files always at once, speeds up Morfik project compilation by 15%
git-svn-id: trunk@6970 -
This commit is contained in:
parent
66a6764d8a
commit
a6f503f263
@ -214,7 +214,7 @@ end;
|
|||||||
|
|
||||||
constructor tobjectreader.create;
|
constructor tobjectreader.create;
|
||||||
begin
|
begin
|
||||||
getmem(buf,bufsize);
|
buf:=nil;
|
||||||
bufidx:=0;
|
bufidx:=0;
|
||||||
bufmax:=0;
|
bufmax:=0;
|
||||||
opened:=false;
|
opened:=false;
|
||||||
@ -225,7 +225,7 @@ destructor tobjectreader.destroy;
|
|||||||
begin
|
begin
|
||||||
if opened then
|
if opened then
|
||||||
closefile;
|
closefile;
|
||||||
freemem(buf,bufsize);
|
freemem(buf);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -238,8 +238,11 @@ begin
|
|||||||
Comment(V_Error,'Can''t open object file: '+fn);
|
Comment(V_Error,'Can''t open object file: '+fn);
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
|
getmem(buf,f.Size);
|
||||||
|
f.read(buf^,f.Size);
|
||||||
|
bufmax:=f.Size;
|
||||||
|
f.free;
|
||||||
bufidx:=0;
|
bufidx:=0;
|
||||||
bufmax:=0;
|
|
||||||
opened:=true;
|
opened:=true;
|
||||||
openfile:=true;
|
openfile:=true;
|
||||||
end;
|
end;
|
||||||
@ -247,7 +250,6 @@ end;
|
|||||||
|
|
||||||
procedure tobjectreader.closefile;
|
procedure tobjectreader.closefile;
|
||||||
begin
|
begin
|
||||||
f.free;
|
|
||||||
opened:=false;
|
opened:=false;
|
||||||
bufidx:=0;
|
bufidx:=0;
|
||||||
bufmax:=0;
|
bufmax:=0;
|
||||||
@ -256,91 +258,29 @@ end;
|
|||||||
|
|
||||||
function tobjectreader.readbuf:boolean;
|
function tobjectreader.readbuf:boolean;
|
||||||
begin
|
begin
|
||||||
bufmax:=f.read(buf^,bufsize);
|
result:=true;
|
||||||
bufidx:=0;
|
|
||||||
readbuf:=(bufmax>0);
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure tobjectreader.seek(len:longint);
|
procedure tobjectreader.seek(len:longint);
|
||||||
begin
|
begin
|
||||||
f.seek(len,soFromBeginning);
|
bufidx:=len;
|
||||||
bufidx:=0;
|
|
||||||
bufmax:=0;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
function tobjectreader.read(out b;len:longint):boolean;
|
function tobjectreader.read(out b;len:longint):boolean;
|
||||||
var
|
|
||||||
p : pchar;
|
|
||||||
lenleft,
|
|
||||||
bufleft,
|
|
||||||
idx : longint;
|
|
||||||
begin
|
begin
|
||||||
result:=false;
|
move(buf[bufidx],b,len);
|
||||||
if bufmax=0 then
|
inc(bufidx,len);
|
||||||
if not readbuf then
|
result:=true;
|
||||||
exit;
|
|
||||||
p:=pchar(@b);
|
|
||||||
idx:=0;
|
|
||||||
lenleft:=len;
|
|
||||||
while lenleft>0 do
|
|
||||||
begin
|
|
||||||
bufleft:=bufmax-bufidx;
|
|
||||||
if lenleft>bufleft then
|
|
||||||
begin
|
|
||||||
move(buf[bufidx],p[idx],bufleft);
|
|
||||||
dec(lenleft,bufleft);
|
|
||||||
inc(idx,bufleft);
|
|
||||||
inc(bufidx,bufleft);
|
|
||||||
if not readbuf then
|
|
||||||
exit;
|
|
||||||
end
|
|
||||||
else
|
|
||||||
begin
|
|
||||||
move(buf[bufidx],p[idx],lenleft);
|
|
||||||
inc(bufidx,lenleft);
|
|
||||||
inc(idx,lenleft);
|
|
||||||
break;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
result:=(idx=len);
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
function tobjectreader.readarray(a:TDynamicArray;len:longint):boolean;
|
function tobjectreader.readarray(a:TDynamicArray;len:longint):boolean;
|
||||||
var
|
|
||||||
orglen,
|
|
||||||
bufleft,
|
|
||||||
idx : longint;
|
|
||||||
begin
|
begin
|
||||||
readarray:=false;
|
a.write(buf[bufidx],len);
|
||||||
if bufmax=0 then
|
|
||||||
if not readbuf then
|
|
||||||
exit;
|
|
||||||
orglen:=len;
|
|
||||||
idx:=0;
|
|
||||||
while len>0 do
|
|
||||||
begin
|
|
||||||
bufleft:=bufmax-bufidx;
|
|
||||||
if len>bufleft then
|
|
||||||
begin
|
|
||||||
a.Write(buf[bufidx],bufleft);
|
|
||||||
dec(len,bufleft);
|
|
||||||
inc(idx,bufleft);
|
|
||||||
inc(bufidx,bufleft);
|
|
||||||
if not readbuf then
|
|
||||||
exit;
|
|
||||||
end
|
|
||||||
else
|
|
||||||
begin
|
|
||||||
a.Write(buf[bufidx],len);
|
|
||||||
inc(bufidx,len);
|
inc(bufidx,len);
|
||||||
inc(idx,len);
|
result:=true;
|
||||||
break;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
readarray:=(idx=orglen);
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function tobjectreader.getfilename : string;
|
function tobjectreader.getfilename : string;
|
||||||
|
Loading…
Reference in New Issue
Block a user