Overview
| Artifact ID: | 58b911baae56a4996a878f652de7ece5363b51c3 |
|---|---|
| Ticket: | 3519865fffffffffffffffffffffffffffffffff
[package require] is too slow |
| User & Date: | dkf on 2012-04-25 19:40:15 |
Changes
- icomment:
If we assume that the contents of a package don't change, just that new packages are installed (each in their own directory tree) then we *can* get a decision on whether to rebuild the cache. Let the cache be a dictionary, indexed by normalized filename with one entry per dir seen in $auto_path (or whatever path is used), stored in the user's home directory (or below; if the user's home directory doesn't exist or isn't writable, we just don't cache; similarly, in a safe interp we don't use the cache either, or at least not unless someone figures out how to make a safe version of it). Then all we need to do is to store the [file mtime] of the dir and compare; if it changes, that means something's been added or removed and we should rebuild. The cache contents should be tuples of exact-normalized-filename-of-pkgIndex.tcl and contents-of-that-pkgIndex.tcl; that would be enough to allow us to synthesize sourcing the file without having to search for it and actually source it. That *should* be enough to boost loading. Users who insist on having /usr/lib in their auto_path get what's due to them for having such ill-considered installations. Probably ought to also have a command to allow flushing of the whole cache or just a part of it. Just in case someone needs something other than what can be done conveniently. Open question: does [file mtime $pathEntry] work suitably for this on Windows? (NB: remember that not all entries on the auto_path exist.) Inspiration code: foreach d $auto_path {if {[file exists $d]} { puts [file normalize $d]:[clock format [file mtime $d]] }} - login: "dkf"
- mimetype: "text/plain"
- username: "dkf"