[138959] contrib/mpab/chroot-scripts/genportlist.tcl

jmr at macports.org jmr at macports.org
Fri Jul 24 20:37:42 PDT 2015


Revision: 138959
          https://trac.macports.org/changeset/138959
Author:   jmr at macports.org
Date:     2015-07-24 20:37:42 -0700 (Fri, 24 Jul 2015)
Log Message:
-----------
mpab: optimise genportlist.tcl in the case of only one port being in the list

Modified Paths:
--------------
    contrib/mpab/chroot-scripts/genportlist.tcl

Modified: contrib/mpab/chroot-scripts/genportlist.tcl
===================================================================
--- contrib/mpab/chroot-scripts/genportlist.tcl	2015-07-25 03:25:11 UTC (rev 138958)
+++ contrib/mpab/chroot-scripts/genportlist.tcl	2015-07-25 03:37:42 UTC (rev 138959)
@@ -53,9 +53,7 @@
     set ::argv [lrange $::argv 2 end]
 }
 
-package require macports
 
-
 proc ui_prefix {priority} {
    return "OUT: "
 }
@@ -82,6 +80,26 @@
 }
 
 
+set todo [list]
+if {[llength $argv] >= 1} {
+    # caller specified a list of ports
+    if {[lindex $argv 0] eq "-"} {
+        while {[gets stdin line] >= 0} {
+            lappend todo [string trim $line]
+        }
+    } else {
+        set todo $argv
+    }
+    # no need to sort a length 1 list
+    if {[llength $todo] == 1} {
+        puts [lindex $todo 0]
+        exit 0
+    }
+}
+
+
+package require macports
+
 if {[catch {mportinit "" "" ""} result]} {
    puts stderr "$errorInfo"
    error "Failed to initialize ports sytem: $result"
@@ -90,7 +108,7 @@
 set depstypes [list depends_fetch depends_extract depends_build depends_lib depends_run]
 array set portdepinfo {}
 
-if {[llength $argv] == 0} {
+if {[llength $todo] == 0} {
     # do all ports
     if {[catch {set search_result [mportlistall]} result]} {
        puts stderr "$errorInfo"
@@ -111,15 +129,6 @@
        array unset portinfo
     }
 } else {
-    # do a specified list of ports
-    if {[lindex $argv 0] eq "-"} {
-        set todo [list]
-        while {[gets stdin line] >= 0} {
-            lappend todo [string trim $line]
-        }
-    } else {
-        set todo $argv
-    }
     # save the ones that the caller actually wants to know about
     foreach p $todo {
         set inputports($p) 1
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/macports-changes/attachments/20150724/ad1ade31/attachment.html>


More information about the macports-changes mailing list