<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/f6985ac966bca0bb50d5d07b497f860729959065">https://github.com/macports/macports-base/commit/f6985ac966bca0bb50d5d07b497f860729959065</a></p>
<pre style="white-space: pre; background: #F8F8F8"><span style='display:block; white-space:pre;color:#808000;'>commit f6985ac966bca0bb50d5d07b497f860729959065
</span>Author: Joshua Root <jmr@macports.org>
AuthorDate: Tue Feb 6 14:24:19 2024 +1100

<span style='display:block; white-space:pre;color:#404040;'>    Reduce array conversions when restoring env
</span>---
 src/port/port.tcl | 26 ++++++++++----------------
 1 file changed, 10 insertions(+), 16 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 c144cd4b1..828214a99 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;'>@@ -1572,9 +1572,9 @@ proc action_help { action portlist opts } {
</span>         # Restore our entire environment from start time.
         # man might want to evaluate TERM
         global env boot_env
<span style='display:block; white-space:pre;background:#ffe0e0;'>-        array unset env_save; array set env_save [array get env]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+        set env_save [array get env]
</span>         array unset env *
<span style='display:block; white-space:pre;background:#ffe0e0;'>-        array set env [array get boot_env]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+        array set env $boot_env
</span> 
         if [catch {system -nodup [list ${macports::autoconf::man_path} $pagepath]} result] {
             ui_debug "$::errorInfo"
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -1584,7 +1584,7 @@ proc action_help { action portlist opts } {
</span> 
         # Restore internal MacPorts environment
         array unset env *
<span style='display:block; white-space:pre;background:#ffe0e0;'>-        array set env [array get env_save]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+        array set env $env_save
</span>     } else {
         ui_error "Sorry, no help for this topic is available."
         return 1
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -3588,14 +3588,12 @@ proc action_list { action portlist opts } {
</span> 
 
 proc action_echo { action portlist opts } {
<span style='display:block; white-space:pre;background:#ffe0e0;'>-    global global_options
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span>     # Simply echo back the port specs given to this command
     foreachport $portlist {
         if {![macports::ui_isset ports_quiet]} {
             set opts [list]
             foreach { key value } $options {
<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;'>+                if {![info exists ::global_options($key)]} {
</span>                     lappend opts "$key=$value"
                 }
             }
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -3620,8 +3618,6 @@ proc action_portcmds { action portlist opts } {
</span>     # Operations on the port's directory and Portfile
     global env boot_env current_portdir
 
<span style='display:block; white-space:pre;background:#ffe0e0;'>-    array set local_options $opts
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span>     set status 0
     if {[require_portlist portlist]} {
         return 1
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -3668,15 +3664,15 @@ proc action_portcmds { action portlist opts } {
</span>                     # Restore our entire environment from start time.
                     # We need it to evaluate the editor, and the editor
                     # may want stuff from it as well, like TERM.
<span style='display:block; white-space:pre;background:#ffe0e0;'>-                    array unset env_save; array set env_save [array get env]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+                    set env_save [array get env]
</span>                     array unset env *
<span style='display:block; white-space:pre;background:#ffe0e0;'>-                    array set env [array get boot_env]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+                    array set env $boot_env
</span> 
                     # Find an editor to edit the portfile
                     set editor ""
                     set editor_var "ports_${action}_editor"
<span style='display:block; white-space:pre;background:#ffe0e0;'>-                    if {[info exists local_options($editor_var)]} {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-                        set editor [join $local_options($editor_var)]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+                    if {[dict exists $opts $editor_var]} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+                        set editor [join [dict get $opts $editor_var]]
</span>                     } else {
                         foreach ed { MP_EDITOR VISUAL EDITOR } {
                             if {[info exists env($ed)]} {
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -3697,7 +3693,7 @@ proc action_portcmds { action portlist opts } {
</span> 
                     # Restore internal MacPorts environment
                     array unset env *
<span style='display:block; white-space:pre;background:#ffe0e0;'>-                    array set env [array get env_save]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+                    array set env $env_save
</span>                 }
 
                 dir {
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -4815,7 +4811,6 @@ namespace eval portclient::progress {
</span>     #        number of units processed and $total is the total number of units
     #        to be processed. If the total is not known, it is 0.
     proc generic {action args} {
<span style='display:block; white-space:pre;background:#ffe0e0;'>-        global env
</span>         variable maxWidth
 
         switch -nocase -- $action {
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -4867,7 +4862,6 @@ namespace eval portclient::progress {
</span>     #        size, currently transferred amount and average speed per second in
     #        bytes. Unused for "finish".
     proc download {action args} {
<span style='display:block; white-space:pre;background:#ffe0e0;'>-        global env
</span>         variable maxWidth
 
         switch -nocase -- $action {
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -5431,7 +5425,7 @@ array set private_options {}
</span> term_init_size
 
 # Save off a copy of the environment before mportinit monkeys with it
<span style='display:block; white-space:pre;background:#ffe0e0;'>-array set boot_env [array get env]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+set boot_env [array get env]
</span> 
 set cmdname [file tail $argv0]
 
</pre><pre style='margin:0'>

</pre>