<pre style='margin:0'>
Joshua Root (jmroot) pushed a commit to branch master
in repository macports-base.

</pre>
<p><a href="https://github.com/macports/macports-base/commit/ba2b81f4ddd3bf103e059ec800c4b06bd7ad21f4">https://github.com/macports/macports-base/commit/ba2b81f4ddd3bf103e059ec800c4b06bd7ad21f4</a></p>
<pre style="white-space: pre; background: #F8F8F8"><span style='display:block; white-space:pre;color:#808000;'>commit ba2b81f4ddd3bf103e059ec800c4b06bd7ad21f4
</span>Author: Joshua Root <jmr@macports.org>
AuthorDate: Tue Feb 13 04:37:45 2024 +1100

<span style='display:block; white-space:pre;color:#404040;'>    Avoid repeated reads of global options and variations
</span>---
 src/port/port.tcl | 35 ++++++++++++++++++++++-------------
 1 file changed, 22 insertions(+), 13 deletions(-)

<span style='display:block; white-space:pre;color:#808080;'>diff --git a/src/port/port.tcl b/src/port/port.tcl
</span><span style='display:block; white-space:pre;color:#808080;'>index daa1e343a..07fbc8c8a 100755
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/src/port/port.tcl
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/src/port/port.tcl
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -422,8 +422,9 @@ proc wraplabel {label string maxlen {indent ""}} {
</span> ##########################################
 proc unique_results_to_portlist {infos} {
     set unique [dict create]
<span style='display:block; white-space:pre;background:#e0ffe0;'>+    set opts [dict create {*}[array get ::global_options]]
</span>     foreach {name portinfo} $infos {
<span style='display:block; white-space:pre;background:#ffe0e0;'>-        set portentry [entry_for_portlist [list url [dict get $portinfo porturl] name $name options [array get ::global_options]]]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+        set portentry [entry_for_portlist [list url [dict get $portinfo porturl] name $name options $opts]]
</span> 
         if {[dict exists $unique [dict get $portentry fullname]]} continue
         dict set unique [dict get $portentry fullname] $portentry
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -783,9 +784,10 @@ proc get_dep_ports {portname recursive} {
</span>     }
     lassign $result portname portinfo
     set porturl [dict get $portinfo porturl]
<span style='display:block; white-space:pre;background:#e0ffe0;'>+    set gvariations [dict create {*}[array get ::global_variations]]
</span> 
     # open portfile
<span style='display:block; white-space:pre;background:#ffe0e0;'>-    if {[catch {set mport [mportopen $porturl [dict create subport $portname] [array get ::global_variations]]} result]} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+    if {[catch {set mport [mportopen $porturl [dict create subport $portname] $gvariations]} result]} {
</span>         ui_debug $::errorInfo
         if {[macports::ui_isset ports_processall]} {
             ui_error "Unable to open port $portname: $result"
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -834,7 +836,7 @@ proc get_dep_ports {portname recursive} {
</span>                     set porturl [dict get $portinfo porturl]
 
                     # open its portfile
<span style='display:block; white-space:pre;background:#ffe0e0;'>-                    if {[catch {set mport [mportopen $porturl [dict create subport [dict get $portinfo name]] [array get ::global_variations]]} result]} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+                    if {[catch {set mport [mportopen $porturl [dict create subport [dict get $portinfo name]] $gvariations]} result]} {
</span>                         ui_debug $::errorInfo
                         ui_error "Unable to open port $depname: $result"
                         continue
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -1237,9 +1239,10 @@ proc add_ports_to_portlist_with_defaults {listname ports {overrides ""}} {
</span> 
     if {![dict exists $overrides options]} {
         set i 0
<span style='display:block; white-space:pre;background:#e0ffe0;'>+        set opts [dict create {*}[array get ::global_options]]
</span>         foreach port $ports {
             if {![dict exists $port options]} {
<span style='display:block; white-space:pre;background:#ffe0e0;'>-                dict set port options [array get ::global_options]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+                dict set port options $opts
</span>                 lset ports $i $port
             }
             incr i
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -1649,6 +1652,7 @@ proc action_info { action portlist opts } {
</span>     }
 
     set separator ""
<span style='display:block; white-space:pre;background:#e0ffe0;'>+    set gvariations [dict create {*}[array get ::global_variations]]
</span>     foreachport $portlist {
         set index_only 0
         if {[dict exists $options ports_info_index] && [dict get $options ports_info_index]} {
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -1674,7 +1678,7 @@ proc action_info { action portlist opts } {
</span>         if {!$index_only} {
             # Add any global_variations to the variations
             # specified for the port (so we get e.g. dependencies right)
<span style='display:block; white-space:pre;background:#ffe0e0;'>-            set merged_variations [dict merge [array get ::global_variations] $variations]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+            set merged_variations [dict merge $gvariations $variations]
</span> 
             if {![dict exists $options subport]} {
                 dict set options subport $portname
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -2072,6 +2076,7 @@ proc action_notes { action portlist opts } {
</span>     }
 
     set status 0
<span style='display:block; white-space:pre;background:#e0ffe0;'>+    set gvariations [dict create {*}[array get ::global_variations]]
</span>     foreachport $portlist {
         if {$porturl eq ""} {
             # Look up the port.
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -2091,7 +2096,7 @@ proc action_notes { action portlist opts } {
</span> 
         # Add any global_variations to the variations
         # specified for the port
<span style='display:block; white-space:pre;background:#ffe0e0;'>-        set merged_variations [dict merge [array get ::global_variations] $variations]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+        set merged_variations [dict merge $gvariations $variations]
</span>         if {![dict exists $options subport]} {
             dict set options subport $portname
         }
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -2640,6 +2645,7 @@ proc action_deps { action portlist opts } {
</span>     }
     set separator ""
     set labeldict [dict create depends_fetch Fetch depends_extract Extract depends_patch Patch depends_build Build depends_lib Library depends_run Runtime depends_test Test]
<span style='display:block; white-space:pre;background:#e0ffe0;'>+    set gvariations [dict create {*}[array get ::global_variations]]
</span> 
     foreachport $portlist {
         set deptypes [list]
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -2693,7 +2699,7 @@ proc action_deps { action portlist opts } {
</span>         if {!([dict exists $options ports_${action}_index] && [dict get $options ports_${action}_index] eq "yes")} {
             # Add any global_variations to the variations
             # specified for the port, so we get dependencies right
<span style='display:block; white-space:pre;background:#ffe0e0;'>-            set merged_variations [dict merge [array get ::global_variations] $variations]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+            set merged_variations [dict merge $gvariations $variations]
</span>             if {![dict exists $options subport]} {
                 dict set options subport $portname
             }
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -3227,6 +3233,7 @@ proc action_variants { action portlist opts } {
</span>     if {[require_portlist portlist]} {
         return 1
     }
<span style='display:block; white-space:pre;background:#e0ffe0;'>+    set gvariations [dict create {*}[array get ::global_variations]]
</span>     foreachport $portlist {
         set portinfo ""
         if {$porturl eq ""} {
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -3247,7 +3254,7 @@ proc action_variants { action portlist opts } {
</span>         if {!([dict exists $options ports_variants_index] && [dict get $options ports_variants_index] eq "yes")} {
             # Add any global_variations to the variations specified for
             # the port (default variants may change based on this)
<span style='display:block; white-space:pre;background:#ffe0e0;'>-            set merged_variations [dict merge [array get ::global_variations] $variations]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+            set merged_variations [dict merge $gvariations $variations]
</span>             if {![dict exists $options subport]} {
                 dict set options subport $portname
             }
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -3290,9 +3297,9 @@ proc action_variants { action portlist opts } {
</span>                     # XXX Keep these varmodifiers in sync with action_info, or create a wrapper for it
                     if {[dict exists $variations $v]} {
                         set varmodifier "  [dict get $variations $v]"
<span style='display:block; white-space:pre;background:#ffe0e0;'>-                    } elseif {[info exists ::global_variations($v)]} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+                    } elseif {[dict exists $gvariations $v]} {
</span>                         # selected by variants.conf, prefixed with (+)/(-)
<span style='display:block; white-space:pre;background:#ffe0e0;'>-                        set varmodifier "($::global_variations($v))"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+                        set varmodifier "([dict get $gvariations $v])"
</span>                     } elseif {[dict exists $variant is_default]} {
                         set varmodifier "\[[dict get $variant is_default]\]"
                     }
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -3518,11 +3525,12 @@ proc action_list { action portlist opts } {
</span> 
 proc action_echo { action portlist opts } {
     # Simply echo back the port specs given to this command
<span style='display:block; white-space:pre;background:#e0ffe0;'>+    set gopts [dict create {*}[array get ::global_options]]
</span>     foreachport $portlist {
         if {![macports::ui_isset ports_quiet]} {
             set opts [list]
<span style='display:block; white-space:pre;background:#ffe0e0;'>-            foreach { key value } $options {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-                if {![info exists ::global_options($key)]} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+            dict for {key value} $options {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+                if {![dict exists $gopts $key]} {
</span>                     lappend opts "$key=$value"
                 }
             }
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -3719,6 +3727,7 @@ proc action_target { action portlist opts } {
</span>     if {($action eq "install" || $action eq "archive") && ![macports::global_option_isset ports_dryrun] && [prefix_unwritable]} {
         return 1
     }
<span style='display:block; white-space:pre;background:#e0ffe0;'>+    set gvariations [dict create {*}[array get ::global_variations]]
</span>     foreachport $portlist {
         set portinfo ""
         # If we have a url, use that, since it's most specific
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -3761,7 +3770,7 @@ proc action_target { action portlist opts } {
</span> 
         # Add any global_variations to the variations
         # specified for the port
<span style='display:block; white-space:pre;background:#ffe0e0;'>-        set requested_variations [dict merge [array get ::global_variations] $requested_variations]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+        set requested_variations [dict merge $gvariations $requested_variations]
</span> 
         if {$action eq "install"} {
             if {[dict exists $portinfo replaced_by] && ![dict exists $options ports_install_no-replace]} {
</pre><pre style='margin:0'>

</pre>