From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3169 invoked by alias); 3 Feb 2011 10:22:28 -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: 28694 Received: (qmail 20317 invoked from network); 3 Feb 2011 10:22:25 -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=-2.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 Received-SPF: pass (ns1.primenet.com.au: SPF record at _spf.google.com designates 209.85.214.171 as permitted sender) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:from:date :message-id:subject:to:content-type:content-transfer-encoding; bh=35RyRzWkPIR150L0EmRiDDtGEt/AzSvO2VR4t7bYhxE=; b=bbaQgMbg4bYpXponSURNq48/nWoBibzY2f2Duo78haEN6s3kGri7/Mdxvy//K5+ZDu 2Kdsp2efACY01UoVxsE1PWsvgPtLwqwfGyO85bjryLeecWb2rNz7pOaP6lKh6c3PIREK O5xywHoZ8ZzGLpJ8rvCR7ZSkIC+FMaehddw0Y= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; b=W9NISt6zxs4+FXY/dSVf07edc6LnieapUWakW3RbxXxHtplwYiJQ3bqDo3RLK7Y51/ 0xJcuXjZUGiOax1C4r527rsatUncsIXW92OHNQJysrrxN/PZBfIOrq+Gy1S/OmeNG6be nPjNz+Sgz3CkSziu0CKOOnt0zsCoQkOUJUfu8= MIME-Version: 1.0 In-Reply-To: <110130160220.ZM15815@torch.brasslantern.com> 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> <110130160220.ZM15815@torch.brasslantern.com> From: cheer_xiao Date: Thu, 3 Feb 2011 18:21:56 +0800 Message-ID: Subject: Re: Slow completion when using aptitude To: Bart Schaefer , zsh-workers@zsh.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Mon, Jan 31, 2011 at 8:02 AM, Bart Schaefer wrote: > 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. =C2=A0The disk cac= he > 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 () { > =C2=A0_deb_packages_update_avail > =C2=A0_deb_packages_update_installed > =C2=A0if (( ! $+_deb_packages_cache_uninstalled )); then > =C2=A0 =C2=A0local avail > =C2=A0 =C2=A0for avail in $_deb_packages_cache_avail > =C2=A0 =C2=A0do > =C2=A0 =C2=A0 =C2=A0 =C2=A0(( ${+_deb_packages_cache_installed[(r)$avail]= } )) && continue > =C2=A0 =C2=A0 =C2=A0 =C2=A0_deb_packages_cache_uninstalledr+=3D( $avail ) > =C2=A0 =C2=A0done > =C2=A0fi > =C2=A0cachevar=3D_deb_packages_cache_uninstalled > } Was I supposed to include this in my .zshrc and that would solve my problem, or was it meant to be a hint for developers on fixing the bug? I have tried the former but nothing seems to change. > > Sometimes the most zsh-ish way to do something isn't the most efficient > way to do it. =C2=A0It may even be still faster to replace the "for" loop > with: > > =C2=A0 =C2=A0_dep_packages_cache_uninstalled=3D( > =C2=A0 =C2=A0 =C2=A0 =C2=A0$( print -l $_deb_packages_cache_avail | > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 fgrep -vf =3D(print -l $_deb_packages_= cache_installed) ) > =C2=A0 =C2=A0) >