<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/cb262dbe8028462b07148959c0a2acf076856a47">https://github.com/macports/macports-base/commit/cb262dbe8028462b07148959c0a2acf076856a47</a></p>
<pre style="white-space: pre; background: #F8F8F8"><span style='display:block; white-space:pre;color:#808000;'>commit cb262dbe8028462b07148959c0a2acf076856a47
</span>Author: Joshua Root <jmr@macports.org>
AuthorDate: Fri Dec 2 18:42:20 2016 +1100
<span style='display:block; white-space:pre;color:#404040;'> Avoid use of 2-arg form of 'array get' in ditem_*
</span><span style='display:block; white-space:pre;color:#404040;'>
</span><span style='display:block; white-space:pre;color:#404040;'> This actually takes a pattern and results in 'string match' being run
</span><span style='display:block; white-space:pre;color:#404040;'> on every key in the array.
</span>---
src/macports1.0/macports_dlist.tcl | 31 +++++++++++++++++++++++--------
1 file changed, 23 insertions(+), 8 deletions(-)
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/src/macports1.0/macports_dlist.tcl b/src/macports1.0/macports_dlist.tcl
</span><span style='display:block; white-space:pre;color:#808080;'>index 0e682fe..abc9df0 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/src/macports1.0/macports_dlist.tcl
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/src/macports1.0/macports_dlist.tcl
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -376,11 +376,14 @@ proc ditem_key {ditem args} {
</span> set nbargs [llength $args]
if {$nbargs > 1} {
set key [lindex $args 0]
<span style='display:block; white-space:pre;background:#ffe0e0;'>- array set $ditem [list $key [lindex $args 1]]
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- return [lindex [array get $ditem $key] 1]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return [set [set ditem]($key) [lindex $args 1]]
</span> } elseif {$nbargs == 1} {
set key [lindex $args 0]
<span style='display:block; white-space:pre;background:#ffe0e0;'>- return [lindex [array get $ditem $key] 1]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {[info exists [set ditem]($key)]} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return [set [set ditem]($key)]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ } else {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return {}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span> } else {
return [array get $ditem]
}
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -388,26 +391,34 @@ proc ditem_key {ditem args} {
</span>
proc ditem_append {ditem key args} {
variable $ditem
<span style='display:block; white-space:pre;background:#ffe0e0;'>- set x [lindex [array get $ditem $key] 1]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {[info exists [set ditem]($key)]} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set x [set [set ditem]($key)]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ } else {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set x {}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span> if {$x ne {}} {
lappend x {*}$args
} else {
set x $args
}
<span style='display:block; white-space:pre;background:#ffe0e0;'>- array set $ditem [list $key $x]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set [set ditem]($key) $x
</span> return $x
}
proc ditem_append_unique {ditem key args} {
variable $ditem
<span style='display:block; white-space:pre;background:#ffe0e0;'>- set x [lindex [array get $ditem $key] 1]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {[info exists [set ditem]($key)]} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set x [set [set ditem]($key)]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ } else {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set x {}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span> if {$x ne {}} {
lappend x {*}$args
set x [lsort -unique $x]
} else {
set x $args
}
<span style='display:block; white-space:pre;background:#ffe0e0;'>- array set $ditem [list $key $x]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set [set ditem]($key) $x
</span> return $x
}
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -416,7 +427,11 @@ proc ditem_contains {ditem key args} {
</span> if {[llength $args] == 0} {
return [info exists [set ditem]($key)]
} else {
<span style='display:block; white-space:pre;background:#ffe0e0;'>- set x [lindex [array get $ditem $key] 1]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {[info exists [set ditem]($key)]} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set x [set [set ditem]($key)]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ } else {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return 0
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span> if {[llength $x] > 0 && [lindex $args 0] in $x} {
return 1
} else {
</pre><pre style='margin:0'>
</pre>