Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Slow completion when using aptitude



On Fri, Feb 4, 2011 at 11:33 AM, Bart Schaefer
<schaefer@xxxxxxxxxxxxxxxx> wrote:
> On Feb 4, 10:49am, cheer_xiao wrote:
> } Subject: Re: Slow completion when using aptitude
> }
> } > } > _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
> } > } > }
> } >
> } > You need to find the file ${^fpath}/_deb_packages and edit it
> } > to replace _deb_packages_update_uninstalled with the above.
> }
> } I tried this, but after typing "sudo aptitude install a" and hit Tab,
> } zsh seems to be trapped in an infinite loop, with one of the CPU cores
> } fully loaded. Should I turn on something else like caching, or is
> } there a flaw in the code you provided?
>
> It's probably still doing too much incremental memory allocation when
> growing the _deb_*_uninstalled array, if there are many thousands of
> packages either installed or available.
>
> Try the other way I suggested:
>
> _deb_packages_update_uninstalled () {
>  _deb_packages_update_avail
>  _deb_packages_update_installed
>  if (( ! $+_deb_packages_cache_uninstalled )); then
>    _dep_packages_cache_uninstalled=(
>      $( print -l $_deb_packages_cache_avail |
>         fgrep -vf =(print -l $_deb_packages_cache_installed)

Seems you have missed a closing parenthesis at the end of line.

>    )
>  fi
> }
>

It's a wonderful fix. zsh now respond within 2 seconds. Thanks a lot!
I wish to see the fix committed into the source repo ASAP. Also the
completion for apt-get should behave the same.



Messages sorted by: Reverse Date, Date, Thread, Author