UPD: Speed up checksum calculation

This commit is contained in:
Alexander Koblov 2024-09-06 23:55:48 +03:00
commit 718d279ea7
2 changed files with 10 additions and 4 deletions

View file

@ -47,7 +47,7 @@ implementation
uses
//Lazarus, Free-Pascal, etc.
LCLProc, LazUTF8, crc,
LCLProc, LazUTF8, DCcrc32,
//DC
uOSUtils, DCOSUtils, uLng, uFileSystemUtil, uFileSystemFileSource,
@ -297,7 +297,10 @@ begin
TotalBytesToRead := TotalBytesToRead - BytesRead;
BytesWritten := 0;
if BytesRead>0 then CurrentCRC32:=crc32(CurrentCRC32,FBuffer,BytesRead);
if BytesRead > 0 then
begin
CurrentCRC32:= crc32_16bytes(FBuffer, BytesRead, CurrentCRC32);
end;
repeat
try

View file

@ -44,7 +44,7 @@ implementation
uses
//Lazarus, Free-Pascal, etc.
LCLProc, LazUTF8, crc,
LCLProc, LazUTF8, DCcrc32,
//DC
DCConvertEncoding, uOSUtils, DCOSUtils, uLng, uFileProcs;
@ -262,7 +262,10 @@ begin
if (BytesRead = 0) then
Raise EReadError.Create(mbSysErrorMessage(GetLastOSError));
if RequireACRC32VerificationFile then CurrentCRC32:=crc32(CurrentCRC32,FBuffer,BytesRead);
if RequireACRC32VerificationFile then
begin
CurrentCRC32:= crc32_16bytes(FBuffer, BytesRead, CurrentCRC32);
end;
TotalBytesToRead := TotalBytesToRead - BytesRead;
BytesWritten := 0;