File 0008-speedup-the-file-compare.patch of Package fdupes

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(-)

Index: fdupes-fdupes-1.51/fdupes.c
===================================================================
--- fdupes-fdupes-1.51.orig/fdupes.c
+++ fdupes-fdupes-1.51/fdupes.c
@@ -370,7 +370,7 @@ char *getcrcsignatureuntil(char *filenam
   }
  
   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);
@@ -606,8 +606,8 @@ int confirmmatch(FILE *file1, FILE *file
   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 */
openSUSE Build Service is sponsored by