Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/cksum Remove calculation of crc_total from here, mak...



details:   https://anonhg.NetBSD.org/src/rev/623377ff83e6
branches:  trunk
changeset: 517285:623377ff83e6
user:      mycroft <mycroft%NetBSD.org@localhost>
date:      Sat Nov 10 05:16:43 2001 +0000

description:
Remove calculation of crc_total from here, making the routine approximately
twice as fast.

diffstat:

 usr.bin/cksum/crc.c |  10 ++--------
 1 files changed, 2 insertions(+), 8 deletions(-)

diffs (50 lines):

diff -r f17b6e192576 -r 623377ff83e6 usr.bin/cksum/crc.c
--- a/usr.bin/cksum/crc.c       Sat Nov 10 05:10:22 2001 +0000
+++ b/usr.bin/cksum/crc.c       Sat Nov 10 05:16:43 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: crc.c,v 1.10 2001/03/21 03:16:38 atatat Exp $  */
+/*     $NetBSD: crc.c,v 1.11 2001/11/10 05:16:43 mycroft Exp $ */
 
 /*-
  * Copyright (c) 1991, 1993
@@ -41,7 +41,7 @@
 #if 0
 static char sccsid[] = "@(#)crc.c      8.1 (Berkeley) 6/17/93";
 #else
-__RCSID("$NetBSD: crc.c,v 1.10 2001/03/21 03:16:38 atatat Exp $");
+__RCSID("$NetBSD: crc.c,v 1.11 2001/11/10 05:16:43 mycroft Exp $");
 #endif
 #endif /* not lint */
 
@@ -111,8 +111,6 @@
  * locations to store the crc and the number of bytes read.  It returns 0 on
  * success and 1 on failure.  Errno is set on failure.
  */
-u_int32_t crc_total = ~0;              /* The crc over a number of files. */
-
 int
 crc(fd, cval, clen)
        register int fd;
@@ -126,11 +124,9 @@
 #define        COMPUTE(var, ch)        (var) = (var) << 8 ^ crctab[(var) >> 24 ^ (ch)]
 
        thecrc = len = 0;
-       crc_total = ~crc_total;
        while ((nr = read(fd, buf, sizeof(buf))) > 0)
                for (len += nr, p = buf; nr--; ++p) {
                        COMPUTE(thecrc, *p);
-                       COMPUTE(crc_total, *p);
                }
        if (nr < 0)
                return (1);
@@ -140,10 +136,8 @@
        /* Include the length of the file. */
        for (; len != 0; len >>= 8) {
                COMPUTE(thecrc, len & 0xff);
-               COMPUTE(crc_total, len & 0xff);
        }
 
        *cval = ~thecrc;
-       crc_total = ~crc_total;
        return (0);
 }



Home | Main Index | Thread Index | Old Index