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

Re: Bug#468386: zsh-beta: Slow command completion



On Mar 2,  4:07pm, Romain Francoise wrote:
}
} Which suggests that most of the time is spent building the arrays
} fed to compadd and/or formatting $descs w/ zformat.  AIUI, before
} your change for 24570 most of the contents of $commands were being
} thrown away, and it's no longer the case.

That's correct.  Before 24570 *all* of the contents of $commands were
being thrown away in some circumstances.  You get a choice between
slow and correct or fast and worthless.

After Clint's 24650 you can also have fast and correct but less helpful
(if the command descriptions really were helpful to begin with).

It belatedly occurs to me that the following might work as a replacement
for ${(k)commands[(I)$PREFIX]} and speed things up, except on the very
first call when the cache is populating (which may take a very long time).

--- ../zsh-forge/current/Completion/Unix/Type/_path_commands	2008-03-02 09:57:33.000000000 -0800
+++ Completion/Unix/Type/_path_commands	2008-03-02 10:10:54.000000000 -0800
@@ -50,9 +50,10 @@
 fi
 
 if [[ -n $need_desc ]]; then
-  typeset -a dcmds descs cmds
+  typeset -a dcmds descs cmds matches
   local desc cmd sep
-  for cmd in ${(k)commands}; do
+  compadd "$@" -O matches -k commands
+  for cmd in $matches; do
     desc=$_command_descriptions[$cmd]
     if [[ -z $desc ]]; then
       cmds+=$cmd



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