mirror of
https://github.com/ckolivas/lrzip.git
synced 2026-04-05 06:15:28 +00:00
Fix md5 process bytes to occur at the same time as crc with the same buffer, saving time.
This commit is contained in:
parent
d1a70bbb90
commit
7287ab8a66
2 changed files with 18 additions and 39 deletions
13
runzip.c
13
runzip.c
|
|
@ -83,6 +83,7 @@ static i64 unzip_literal(void *ss, i64 len, int fd_out, uint32 *cksum)
|
|||
fatal("Failed to write literal buffer of size %lld\n", stream_read);
|
||||
|
||||
*cksum = CrcUpdate(*cksum, buf, stream_read);
|
||||
md5_process_bytes(buf, stream_read, &control.ctx);
|
||||
|
||||
free(buf);
|
||||
return stream_read;
|
||||
|
|
@ -122,6 +123,7 @@ static i64 unzip_match(void *ss, i64 len, int fd_out, int fd_hist, uint32 *cksum
|
|||
fatal("Failed to write %d bytes in unzip_match\n", n);
|
||||
|
||||
*cksum = CrcUpdate(*cksum, off_buf, n);
|
||||
md5_process_bytes(off_buf, n, &control.ctx);
|
||||
|
||||
len -= n;
|
||||
off_buf += n;
|
||||
|
|
@ -231,24 +233,15 @@ i64 runzip_fd(int fd_in, int fd_out, int fd_hist, i64 expected_size)
|
|||
int j;
|
||||
|
||||
md5_init_ctx (&control.ctx);
|
||||
md5_stream = fopen(control.outfile, "r");
|
||||
if (unlikely(md5_stream == NULL))
|
||||
fatal("Failed to fdopen md5_stream in runzip_fd\n");
|
||||
|
||||
gettimeofday(&start,NULL);
|
||||
|
||||
while (total < expected_size) {
|
||||
while (total < expected_size)
|
||||
total += runzip_chunk(fd_in, fd_out, fd_hist, expected_size, total);
|
||||
if (md5_midstream(md5_stream, &control.ctx))
|
||||
fatal("Failed md5_midstream in runzip_fd\n");
|
||||
}
|
||||
|
||||
gettimeofday(&end,NULL);
|
||||
print_progress("\nAverage DeCompression Speed: %6.3fMB/s\n",
|
||||
(total / 1024 / 1024) / (double)((end.tv_sec-start.tv_sec)? : 1));
|
||||
|
||||
if (unlikely(fclose(md5_stream)))
|
||||
fatal("Failed to fclose md5_stream in runzip_fd\n");
|
||||
md5_finish_ctx (&control.ctx, md5_resblock);
|
||||
if (HASH_CHECK || VERBOSE) {
|
||||
print_output("MD5 sum: ");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue