From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1864 invoked by alias); 31 Jan 2011 00:02:30 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 28687 Received: (qmail 2538 invoked from network); 31 Jan 2011 00:02:27 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received-SPF: none (ns1.primenet.com.au: domain at closedmail.com does not designate permitted sender hosts) From: Bart Schaefer Message-id: <110130160220.ZM15815@torch.brasslantern.com> Date: Sun, 30 Jan 2011 16:02:20 -0800 In-reply-to: Comments: In reply to Julien Nicoulaud "Re: Slow completion when using aptitude" (Jan 30, 11:51am) References: <87oc74dpuy.fsf@ft.bewatermyfriend.org> <87d3njemu9.fsf@ft.bewatermyfriend.org> <110126090508.ZM2111@torch.brasslantern.com> <110126092944.ZM2205@torch.brasslantern.com> <110129211610.ZM21714@torch.brasslantern.com> <110129231514.ZM21967@torch.brasslantern.com> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: Julien Nicoulaud Subject: Re: Slow completion when using aptitude Cc: cheer_xiao , zsh-workers@zsh.org MIME-version: 1.0 Content-type: text/plain; charset=us-ascii On Jan 30, 11:51am, Julien Nicoulaud wrote: } } By the way, this issue was already known: } http://www.zsh.org/mla/workers/2008/msg00930.html So ... _deb_packages_update_avail uses the cache to populate an array variable of the same name. As does _deb_packages_update_installed. Then _deb_packages_update_uninstalled constructs a massive glob pattern from the results of the latter, and applies it as a filter against the former, to set a variable _deb_packages_update_uninstalled. Thereafter the value of _deb_packages_update_uninstalled is used rather than go through that filter again, so it *is* caching. The disk cache isn't used by _deb*_uninstalled because the files are all on the disk already from the other two functions. All the time is being spent building that glob pattern, and filtering. So try using this instead: _deb_packages_update_uninstalled () { _deb_packages_update_avail _deb_packages_update_installed if (( ! $+_deb_packages_cache_uninstalled )); then local avail for avail in $_deb_packages_cache_avail do (( ${+_deb_packages_cache_installed[(r)$avail]} )) && continue _deb_packages_cache_uninstalledr+=( $avail ) done fi cachevar=_deb_packages_cache_uninstalled } Sometimes the most zsh-ish way to do something isn't the most efficient way to do it. It may even be still faster to replace the "for" loop with: _dep_packages_cache_uninstalled=( $( print -l $_deb_packages_cache_avail | fgrep -vf =(print -l $_deb_packages_cache_installed) ) )