[138099] trunk/base/src

jmr at macports.org jmr at macports.org
Sun Jun 28 00:25:25 PDT 2015


Revision: 138099
          https://trac.macports.org/changeset/138099
Author:   jmr at macports.org
Date:     2015-06-28 00:25:25 -0700 (Sun, 28 Jun 2015)
Log Message:
-----------
use in or ni operators where possible, rather than comparing the return value of lsearch with -1

Modified Paths:
--------------
    trunk/base/src/macports1.0/macports.tcl
    trunk/base/src/macports1.0/macports_dlist.tcl
    trunk/base/src/port1.0/portchecksum.tcl
    trunk/base/src/port1.0/portconfigure.tcl
    trunk/base/src/port1.0/portdestroot.tcl
    trunk/base/src/port1.0/portlint.tcl
    trunk/base/src/port1.0/portlivecheck.tcl
    trunk/base/src/port1.0/portutil.tcl
    trunk/base/src/registry2.0/portimage.tcl

Modified: trunk/base/src/macports1.0/macports.tcl
===================================================================
--- trunk/base/src/macports1.0/macports.tcl	2015-06-28 07:13:39 UTC (rev 138098)
+++ trunk/base/src/macports1.0/macports.tcl	2015-06-28 07:25:25 UTC (rev 138099)
@@ -690,7 +690,7 @@
             set fd [open $file r]
             while {[gets $fd line] >= 0} {
                 if {[regexp {^(\w+)([ \t]+(.*))?$} $line match option ignore val] == 1} {
-                    if {[lsearch -exact $bootstrap_options $option] >= 0} {
+                    if {$option in $bootstrap_options} {
                         set macports::$option [string trim $val]
                         global macports::$option
                     }
@@ -706,7 +706,7 @@
         set fd [open $per_user r]
         while {[gets $fd line] >= 0} {
             if {[regexp {^(\w+)([ \t]+(.*))?$} $line match option ignore val] == 1} {
-                if {[lsearch -exact $user_options $option] >= 0} {
+                if {$option in $user_options} {
                     set macports::$option $val
                     global macports::$option
                 }
@@ -725,7 +725,7 @@
             if {[regexp {^([\w-]+://\S+)(?:\s+\[(\w+(?:,\w+)*)\])?$} $line _ url flags]} {
                 set flags [split $flags ,]
                 foreach flag $flags {
-                    if {[lsearch -exact [list nosync default] $flag] == -1} {
+                    if {$flag ni [list nosync default]} {
                         ui_warn "$sources_conf source '$line' specifies invalid flag '$flag'"
                     }
                     if {$flag eq "default"} {
@@ -1080,7 +1080,7 @@
 
     set env_names [array names env]
     foreach envkey $env_names {
-        if {[lsearch -exact $keepenvkeys $envkey] == -1} {
+        if {$envkey ni $keepenvkeys} {
             unset env($envkey)
         }
     }
@@ -1088,7 +1088,7 @@
     # unset environment an extra time, to work around bugs in Leopard Tcl
     if {$macosx_version eq "10.5"} {
         foreach envkey $env_names {
-            if {[lsearch -exact $keepenvkeys $envkey] == -1} {
+            if {$envkey ni $keepenvkeys} {
                 unsetenv $envkey
             }
         }
@@ -2206,13 +2206,13 @@
                         }
                     }
                     if {[llength $missing] > 0} {
-                        if {[info exists dep_portinfo(variants)] && [lsearch -exact $dep_portinfo(variants) universal] != -1} {
+                        if {[info exists dep_portinfo(variants)] && "universal" in $dep_portinfo(variants)} {
                             # dep offers a universal variant
                             if {[llength $active_archs] == 1} {
                                 # not installed universal
                                 set missing {}
                                 foreach arch $required_archs {
-                                    if {[lsearch -exact $macports::universal_archs $arch] == -1} {
+                                    if {$arch ni $macports::universal_archs} {
                                         lappend missing $arch
                                     }
                                 }
@@ -2422,7 +2422,7 @@
     foreach source $sources {
         set flags [lrange $source 1 end]
         set source [lindex $source 0]
-        if {[lsearch -exact $flags nosync] != -1} {
+        if {"nosync" in $flags} {
             ui_debug "Skipping $source"
             continue
         }
@@ -3341,7 +3341,7 @@
         return 1
     }
     foreach arch $required_archs {
-        if {[lsearch -exact $provided_archs $arch] == -1} {
+        if {$arch ni $provided_archs} {
             return 0
         }
     }
@@ -3397,7 +3397,7 @@
     if {$supported_archs ne ""} {
         set ss [expr {[llength $supported_archs] == 1 ? "" : "s"}]
         foreach arch $required_archs {
-            if {[lsearch -exact $supported_archs $arch] == -1} {
+            if {$arch ni $supported_archs} {
                 ui_error "its dependency $dep only supports the arch${ss} '$supported_archs'."
                 return
             }
@@ -3405,7 +3405,7 @@
     }
     if {$has_universal} {
         foreach arch $required_archs {
-            if {[lsearch -exact $universal_archs $arch] == -1} {
+            if {$arch ni $universal_archs} {
                 ui_error "its dependency $dep does not build for the required arch${s} by default"
                 ui_error "and the configured universal_archs '$universal_archs' are not sufficient."
                 return
@@ -5088,7 +5088,7 @@
             set fd [open $conf_file r]
             while {[gets $fd line] >= 0} {
                 if {[regexp {^(\w+)([ \t]+(.*))?$} $line match option ignore val] == 1} {
-                    if {[lsearch -exact $conf_options $option] >= 0} {
+                    if {$option in $conf_options} {
                         if {$option eq "name"} {
                             set cur_name $val
                             lappend all_names $val

Modified: trunk/base/src/macports1.0/macports_dlist.tcl
===================================================================
--- trunk/base/src/macports1.0/macports_dlist.tcl	2015-06-28 07:13:39 UTC (rev 138098)
+++ trunk/base/src/macports1.0/macports_dlist.tcl	2015-06-28 07:25:25 UTC (rev 138099)
@@ -415,7 +415,7 @@
 		return [info exists [set ditem]($key)]
 	} else {
 		set x [lindex [array get $ditem $key] 1]
-		if {[llength $x] > 0 && [lsearch -exact $x [lindex $args 0]] != -1} {
+		if {[llength $x] > 0 && [lindex $args 0] in $x} {
 			return 1
 		} else {
 			return 0

Modified: trunk/base/src/port1.0/portchecksum.tcl
===================================================================
--- trunk/base/src/port1.0/portchecksum.tcl	2015-06-28 07:13:39 UTC (rev 138098)
+++ trunk/base/src/port1.0/portchecksum.tcl	2015-06-28 07:25:25 UTC (rev 138099)
@@ -84,7 +84,7 @@
     if {[llength $all_dist_files] == 1
         && [expr {$nb_checksum % 2}] == 0
         && [expr {$nb_checksum / 2}] <= $checksum_types_count
-        && [lsearch -exact $checksum_types [lindex $checksums_str 0]] >= 0} {
+        && [lindex $checksums_str 0] in $checksum_types} {
         # Convert to format #2
         set checksums_str [linsert $checksums_str 0 [lindex $all_dist_files 0]]
         # We increased the size.
@@ -113,7 +113,7 @@
             incr ix_checksum
             while {1} {
                 set checksum_type [lindex $checksums_str $ix_checksum]
-                if {[lsearch -exact $checksum_types $checksum_type] >= 0} {
+                if {$checksum_type in $checksum_types} {
                     # append the type and the value.
                     incr ix_checksum
                     set checksum_value [lindex $checksums_str $ix_checksum]

Modified: trunk/base/src/port1.0/portconfigure.tcl
===================================================================
--- trunk/base/src/port1.0/portconfigure.tcl	2015-06-28 07:13:39 UTC (rev 138098)
+++ trunk/base/src/port1.0/portconfigure.tcl	2015-06-28 07:25:25 UTC (rev 138099)
@@ -325,16 +325,16 @@
     }
     set ret {}
     foreach arch $archs {
-        if {[lsearch -exact $supported_archs $arch] != -1} {
+        if {$arch in $supported_archs} {
             set add_arch $arch
-        } elseif {$arch eq "x86_64" && [lsearch -exact $supported_archs "i386"] != -1} {
+        } elseif {$arch eq "x86_64" && "i386" in $supported_archs} {
             set add_arch "i386"
-        } elseif {$arch eq "ppc64" && [lsearch -exact $supported_archs "ppc"] != -1} {
+        } elseif {$arch eq "ppc64" && "ppc" in $supported_archs} {
             set add_arch "ppc"
         } else {
             continue
         }
-        if {[lsearch -exact $ret $add_arch] == -1} {
+        if {$add_arch ni $ret} {
             lappend ret $add_arch
         }
     }

Modified: trunk/base/src/port1.0/portdestroot.tcl
===================================================================
--- trunk/base/src/port1.0/portdestroot.tcl	2015-06-28 07:13:39 UTC (rev 138098)
+++ trunk/base/src/port1.0/portdestroot.tcl	2015-06-28 07:25:25 UTC (rev 138099)
@@ -341,7 +341,7 @@
                         if {$pfile eq "." || $pfile eq ".."} {
                             continue
                         }
-                        if {[lsearch -exact $prefixPaths $pfile] == -1} {
+                        if {$pfile ni $prefixPaths} {
                             ui_warn "violation by [file join $dfile $pfile]"
                             set mtree_violation "yes"
                         }

Modified: trunk/base/src/port1.0/portlint.tcl
===================================================================
--- trunk/base/src/port1.0/portlint.tcl	2015-06-28 07:13:39 UTC (rev 138098)
+++ trunk/base/src/port1.0/portlint.tcl	2015-06-28 07:25:25 UTC (rev 138099)
@@ -403,7 +403,7 @@
 
     if {[info exists platforms]} {
         foreach platform $platforms {
-            if {[lsearch -exact $lint_platforms $platform] == -1} {
+            if {$platform ni $lint_platforms} {
                 ui_error "Unknown platform: $platform"
                 incr errors
             } else {
@@ -450,7 +450,7 @@
 
             if {![info exists variantdesc] || $variantdesc eq ""} {
                 # don't warn about missing descriptions for global variants
-                if {[lsearch -exact $local_variants $variantname] != -1 &&
+                if {$variantname in $local_variants &&
                     [variant_desc $porturl $variantname] eq ""} {
                     ui_warn "Variant $variantname does not have a description"
                     incr warnings

Modified: trunk/base/src/port1.0/portlivecheck.tcl
===================================================================
--- trunk/base/src/port1.0/portlivecheck.tcl	2015-06-28 07:13:39 UTC (rev 138098)
+++ trunk/base/src/port1.0/portlivecheck.tcl	2015-06-28 07:25:25 UTC (rev 138099)
@@ -130,7 +130,7 @@
             }
         }
     }
-    if {[lsearch -exact [split $available_types "|"] ${livecheck.type}] != -1} {
+    if {${livecheck.type} in [split $available_types "|"]} {
         # Load the defaults from _resources/port1.0/livecheck/${livecheck.type}.tcl.
         set defaults_file "$types_dir/${livecheck.type}.tcl"
         ui_debug "Loading the defaults from '$defaults_file'"

Modified: trunk/base/src/port1.0/portutil.tcl
===================================================================
--- trunk/base/src/port1.0/portutil.tcl	2015-06-28 07:13:39 UTC (rev 138098)
+++ trunk/base/src/port1.0/portutil.tcl	2015-06-28 07:25:25 UTC (rev 138099)
@@ -702,8 +702,7 @@
 # determine if a variant exists.
 proc variant_exists {name} {
     global PortInfo
-    if {[info exists PortInfo(variants)] &&
-      [lsearch -exact $PortInfo(variants) $name] >= 0} {
+    if {[info exists PortInfo(variants)] && $name in $PortInfo(variants)} {
         return 1
     }
 
@@ -814,7 +813,7 @@
 proc subport {subname body} {
     global subport name PortInfo
     if {$subport eq $name && $subname ne $name && 
-        (![info exists PortInfo(subports)] || [lsearch -exact $PortInfo(subports) $subname] == -1)} {
+        (![info exists PortInfo(subports)] || $subname ni $PortInfo(subports))} {
         lappend PortInfo(subports) $subname
     }
     if {[string equal -nocase $subname $subport]} {
@@ -1395,7 +1394,7 @@
             }
 
             # Of course, if this is a dry run, don't do the task:
-            if {[tbool ports_dryrun] && [lsearch -exact $dryrun_allow_targets $targetname] == -1} {
+            if {[tbool ports_dryrun] && $targetname ni $dryrun_allow_targets} {
                 # only one message per portname
                 if {$portname != $ports_dry_last_skipped} {
                     ui_notice "For $portname: skipping $targetname (dry run)"
@@ -1489,11 +1488,9 @@
 
                         # If portname is empty, the dependency is already satisfied by other means,
                         # for example a bin: dependency on a file not installed by MacPorts
-                        if {$name ne ""} {
-                            if {[lsearch -exact $deplist $name] == -1} {
-                                lappend deplist $name
-                                set deplist [recursive_collect_deps $name $deplist]
-                            }
+                        if {$name ne "" && $name ni $deplist} {
+                            lappend deplist $name
+                            set deplist [recursive_collect_deps $name $deplist]
                         }
                     }
 
@@ -1629,7 +1626,7 @@
 
     foreach item $deplist {
         set name [lindex $item 0]
-        if {[lsearch -exact $depsfound $name] == -1} {
+        if {$name ni $depsfound} {
             lappend depsfound $name
             set depsfound [recursive_collect_deps $name $depsfound]
         }
@@ -2048,7 +2045,7 @@
     array set requested_variations [array get upvariations]
     foreach key [array names upvariations *] {
         if {![info exists PortInfo(variants)] ||
-            [lsearch $PortInfo(variants) $key] == -1} {
+            $key ni $PortInfo(variants)} {
             ui_debug "Requested variant $upvariations($key)$key is not provided by port $portname."
             array unset upvariations $key
         }

Modified: trunk/base/src/registry2.0/portimage.tcl
===================================================================
--- trunk/base/src/registry2.0/portimage.tcl	2015-06-28 07:13:39 UTC (rev 138098)
+++ trunk/base/src/registry2.0/portimage.tcl	2015-06-28 07:25:25 UTC (rev 138099)
@@ -534,7 +534,7 @@
                 # we'll set the directory attributes properly for all
                 # directories.
                 set directory [::file dirname $file]
-                while { [lsearch -exact $files $directory] == -1 } {
+                while {$directory ni $files} {
                     lappend files $directory
                     set directory [::file dirname $directory]
                 }
@@ -688,7 +688,7 @@
 
             # Split out the filename's subpaths and add them to the image list
             # as well.
-            while { [lsearch -exact $files $directory] == -1 } {
+            while {$directory ni $files} {
                 lappend files $directory
                 set directory [::file dirname $directory]
             }
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/macports-changes/attachments/20150628/4e3711bb/attachment-0001.html>


More information about the macports-changes mailing list