pkgsrc-Changes-HG archive

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

[pkgsrc/trunk]: pkgsrc/mk/checksum Speed up the algorithm to determine the fi...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/acb330b261d0
branches:  trunk
changeset: 609927:acb330b261d0
user:      jmmv <jmmv%pkgsrc.org@localhost>
date:      Sat Oct 13 15:31:23 2012 +0000

description:
Speed up the algorithm to determine the files left to check.

This change modifies the algorithm used to keep track of the files that
have not yet been checksummed to use a simple loop instead of shell pattern
matching.

For packages with few distinfo entries, either way yields the same result
as the list of files to check is very short.  But for those packages with
hundreds of distinfo entries (vim, I'm looking at you), the difference is
huge.  In my old macppc machine, the checksum of vim used to take around
40 minutes and now it takes ~35 seconds.  The difference is also clearly
visible in my faster amd64 machine (although I haven't bothered to time it).

diffstat:

 mk/checksum/checksum |  19 +++++++------------
 1 files changed, 7 insertions(+), 12 deletions(-)

diffs (35 lines):

diff -r 34d00245d478 -r acb330b261d0 mk/checksum/checksum
--- a/mk/checksum/checksum      Sat Oct 13 12:26:59 2012 +0000
+++ b/mk/checksum/checksum      Sat Oct 13 15:31:23 2012 +0000
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# $NetBSD: checksum,v 1.12 2007/08/15 13:56:24 jlam Exp $
+# $NetBSD: checksum,v 1.13 2012/10/13 15:31:23 jmmv Exp $
 #
 # Copyright (c) 2006, 2007 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -156,17 +156,12 @@
                ${TEST} -z "$patch" || sfile="${sfile##*/}"
                ${TEST} "$d_file" = "($sfile)" || continue
 
-               case "$files_left" in
-               "$file"|"$file "*)      pre= ;;
-               *" $file")              pre="${files_left%% $file}" ;;
-               *)                      pre="${files_left%% $file *} " ;;
-               esac
-               case "$files_left" in
-               "$file"|*" $file")      post= ;;
-               "$file "*)              post="${files_left##$file }" ;;
-               *)                      post="${files_left##* $file }" ;;
-               esac
-               files_left="${pre}${post}"
+               new_files_left=
+               for file_left in $files_left; do
+                       ${TEST} "${file_left}" = "${file}" || \
+                           new_files_left="${new_files_left} ${file_left}"
+               done
+               files_left="${new_files_left}"
 
                if ${TEST} "$d_checksum" = "IGNORE"; then
                        ${ECHO} 1>&2 "$self: Ignoring checksum for $sfile"



Home | Main Index | Thread Index | Old Index