forked from pool/fdupes
40 lines
1.3 KiB
Diff
40 lines
1.3 KiB
Diff
|
From c2bd76bb103b3a5b873bee72fbacce6bbe58bbe2 Mon Sep 17 00:00:00 2001
|
||
|
From: =?UTF-8?q?Stefan=20Br=C3=BCns?= <stefan.bruens@rwth-aachen.de>
|
||
|
Date: Fri, 12 Oct 2012 15:20:53 +0200
|
||
|
Subject: [PATCH 08/10] speedup the file compare
|
||
|
|
||
|
Use aligned reads for md5 computation, saves another memcpy.
|
||
|
|
||
|
https://bugzilla.novell.com/show_bug.cgi?id=406825
|
||
|
---
|
||
|
fdupes.c | 6 +++---
|
||
|
1 file changed, 3 insertions(+), 3 deletions(-)
|
||
|
|
||
|
diff --git a/fdupes.c b/fdupes.c
|
||
|
index 1e9e620..678f31f 100644
|
||
|
--- a/fdupes.c
|
||
|
+++ b/fdupes.c
|
||
|
@@ -370,7 +370,7 @@ char *getcrcsignatureuntil(char *filename, off_t max_read)
|
||
|
}
|
||
|
|
||
|
while (fsize > 0) {
|
||
|
- toread = (fsize % CHUNK_SIZE) ? (fsize % CHUNK_SIZE) : CHUNK_SIZE;
|
||
|
+ toread = (fsize >= CHUNK_SIZE) ? CHUNK_SIZE : fsize;
|
||
|
if (fread(chunk, toread, 1, file) != 1) {
|
||
|
errormsg("error reading from file %s\n", filename);
|
||
|
fclose(file); // bugfix
|
||
|
@@ -606,8 +606,8 @@ int confirmmatch(FILE *file1, FILE *file2)
|
||
|
fseek(file2, 0, SEEK_SET);
|
||
|
|
||
|
do {
|
||
|
- r1 = fread(c1, 1, sizeof(c1), file1);
|
||
|
- r2 = fread(c2, 1, sizeof(c2), file2);
|
||
|
+ r1 = fread(c1, sizeof(unsigned char), sizeof(c1), file1);
|
||
|
+ r2 = fread(c2, sizeof(unsigned char), sizeof(c2), file2);
|
||
|
|
||
|
if (r1 != r2) return 0; /* file lengths are different */
|
||
|
if (memcmp (c1, c2, r1)) return 0; /* file contents are different */
|
||
|
--
|
||
|
1.7.11.5
|
||
|
|