Skip to content
Tcl Source Code View Ticket
Login

View Ticket

speeding up tclPkgUnknown

Closed / Fixed218379ffffffffffffffffffffffffffffffffffCreated 26 years agoUpdated 26 years ago
Descriptionplain2000-10-26 00:56:53
OriginalBugID: 4355 RFE
Version: 8.2.3
SubmitDate: '2000-03-10'
LastModified: '2000-08-15'
Severity: LOW
Status: Closed
Submitter: techsupp
ChangedBy: ericm
OS: BSD
OSVersion: FreeBSD-4.0 -current
Machine: Dual PIII-450
FixedDate: '2000-10-25'
ClosedDate: '2000-08-15'


Name:

Mikhail Teterin


Extensions:

TclX, SQL


ObservedBehavior:

The implementation of tclPkgUnknown uses for(n) loop to go through the auto_path list.


DesiredBehavior:

Using the foreach(n) loop is much neater and speedier, although the speed difference is hardly noticeable.


Patch:

--- library/package.tclWed Apr 21 17:50:29 1999

+++ library/package.tclThu Mar  9 22:41:39 2000

@@ -438,3 +438,3 @@

     }

-    for {set i [expr {[llength $auto_path] - 1}]} {$i >= 0} {incr i -1} {

+    foreach d $auto_path {

 # we can't use glob in safe interps, so enclose the following

@@ -442,4 +442,3 @@

 catch {

-    foreach file [glob -nocomplain [file join [lindex $auto_path $i] \

-    * pkgIndex.tcl]] {

+    foreach file [glob -nocomplain [file join $d * pkgIndex.tcl]] {

 set dir [file dirname $file]

@@ -452,3 +451,3 @@

 }

-set dir [lindex $auto_path $i]

+set dir $d

 set file [file join $dir pkgIndex.tcl]

@@ -466,5 +465,4 @@

     tclMacPkgSearch $dir

-    foreach x [glob -nocomplain [file join $dir *]] {

-if {[file isdirectory $x]} {

-    set dir $x

+    foreach dir [glob -nocomplain [file join $dir *]] {

+if {[file isdirectory $dir]} {

     tclMacPkgSearch $dir


PatchFiles:

library/package.tcl




This changes the order in which auto_path is processed -- instead of last to first, it is read first to last.  The implications of that must be investigated.

- eric

-- 03/10/2000 ericm

Because this changes the order of auto_path searches, I think this modification should not be made.  The benefit of searching auto_path last to first is that applications can append items and be guaranteed that their libraries will be found first, giving them an opportunity to override system defaults.

As you noted, the speed gain is negligable, so it's not clear that there's even a siginificant benefit to be gained from applying this patch.  The cleaner code is nice, but at the cost of backwards incompatibility, it is probably not worth it.  Perhaps with the [listx reverse] command that ought to be in 8.4, we can clean the code and retain backwards compatibility.

   Eric Melski                            The Other Tcl Guy
   ericm at ajubasolutions.com            Ajuba Solutions

-- 08/15/2000 ericm
welch Closed ticket [218379ffff]. [History diff]2000-10-26 08:21:16
dgp Open ticket [218379ffff]. [History diff]2001-04-06 02:10:29
dgp Closed ticket [218379ffff]. [History diff]2001-04-06 02:12:12
Log in (anonymous is fine) to add a comment.