Re: Cache complex list for faster performance




Kevin Walzer wrote:
The key variable in question here is "portlist." That's the final list
that is dumped into the tablelist widget. How can I store/cache the
entire contents of $portlist so that I can parse/query it as needed? If
it's feasible to do this as a global variable, I haven't figured out how
to do it--trying later to find "portlist" only returns the first item of
the list. The list has about 4,000 items in it, each line of the list
structured as {$myinstalled $program $version $searchcategory}.

In this line

set portlist [list $myinstalled $program $version $searchcategory]

you set the portlist always to a new value. If you want to save/cache the
results, you should append to portlist, otherwise you overwrite your
previous settings. Maybe, you mean something like

lappend portlist [list $myinstalled $program $version $searchcategory]

But then you have to change the next line also to

.t.right.upper.frame.listbox insert end [lindex $portlist end]

otherwise you would insert the whole (growing) list into your widget.

HTH
Stephan

.