[84985] trunk/base/src/port1.0/portchecksum.tcl

snc at macports.org snc at macports.org
Thu Oct 6 08:55:44 PDT 2011


Revision: 84985
          http://trac.macports.org/changeset/84985
Author:   snc at macports.org
Date:     2011-10-06 08:55:43 -0700 (Thu, 06 Oct 2011)
Log Message:
-----------
base: avoid double calculating of checksums

Modified Paths:
--------------
    trunk/base/src/port1.0/portchecksum.tcl

Modified: trunk/base/src/port1.0/portchecksum.tcl
===================================================================
--- trunk/base/src/port1.0/portchecksum.tcl	2011-10-06 14:40:51 UTC (rev 84984)
+++ trunk/base/src/port1.0/portchecksum.tcl	2011-10-06 15:55:43 UTC (rev 84985)
@@ -221,6 +221,9 @@
     # Set the list of checksums as the option checksums.
     set checksums_str [option checksums]
 
+    # store the calculated checksums to avoid repeated calculations
+    set sums ""
+
     # if everything is fine with the syntax, keep on and check the checksum of
     # the distfiles.
     if {[parse_checksums $checksums_str] == "yes"} {
@@ -250,6 +253,7 @@
                 # iterate on this list to check the actual values.
                 foreach {type sum} $portfile_checksums {
                     set calculated_sum [calc_$type $fullpath]
+                    lappend sums [format "%-8s%s" $type $calculated_sum]
                     if {[string equal $sum $calculated_sum]} {
                         ui_debug "[format [msgcat::mc "Correct (%s) checksum for %s"] $type $distfile]"
                     } else {
@@ -278,7 +282,6 @@
     if {[tbool fail]} {
 
         # Show the desired checksum line for easy cut-paste
-        set sums ""
         foreach distfile $all_dist_files {
             if {[llength $all_dist_files] > 1} {
                 lappend sums $distfile
@@ -293,11 +296,6 @@
                 foreach type $default_checksum_types {
                     lappend sums [format "%-8s%s" $type [calc_$type $fullpath]]
                 }
-            } else {
-                # output just the types that were already used
-                foreach {type sum} $checksums_array($distfile) {
-                    lappend sums [format "%-8s%s" $type [calc_$type $fullpath]]
-                }
             }
         }
         ui_info "The correct checksum line may be:"
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20111006/dbe1fb46/attachment.html>


More information about the macports-changes mailing list