about summary refs log tree commit diff
diff options
context:
space:
mode:
authorSven Wischnowsky <wischnow@users.sourceforge.net>2000-06-07 11:21:42 +0000
committerSven Wischnowsky <wischnow@users.sourceforge.net>2000-06-07 11:21:42 +0000
commit25ca4f8792b99cc127f04ad059e0c66cb6e0face (patch)
treec9fdf61fdddd3dd9f623b09cc011b6ae2c03e233
parentb24757fc343f8ff2d54fb2e5ab089d3fdab13c01 (diff)
downloadzsh-25ca4f8792b99cc127f04ad059e0c66cb6e0face.tar.gz
zsh-25ca4f8792b99cc127f04ad059e0c66cb6e0face.tar.xz
zsh-25ca4f8792b99cc127f04ad059e0c66cb6e0face.zip
optimise command lookup in old and new completion (user/3124)
-rw-r--r--ChangeLog3
-rw-r--r--Completion/Core/_normal49
-rw-r--r--Src/Zle/compctl.c7
3 files changed, 36 insertions, 23 deletions
diff --git a/ChangeLog b/ChangeLog
index ccf2feaad..3ce390c64 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -6,6 +6,9 @@
 
 2000-06-07  Sven Wischnowsky  <wischnow@zsh.org>
 
+	* user/3124: Completion/Core/_normal, Src/Zle/compctl.c: optimise
+ 	command lookup in old and new completion
+	
 	* 11794: Src/Zle/compcore.c, Src/Zle/complist.c, Src/Zle/zle_tricky.c:
  	hopefully more consistent beeping with menu-selection
 	
diff --git a/Completion/Core/_normal b/Completion/Core/_normal
index 52f0bb352..e0375e077 100644
--- a/Completion/Core/_normal
+++ b/Completion/Core/_normal
@@ -23,11 +23,14 @@ if [[ CURRENT -eq 1 ]]; then
 
   return ret
 else
-  if [[ "$command[1]" == '=' ]]; then
+  if (( $+builtins[$command] + $+functions[$command] )); then
+    cmd1="$command"
+    curcontext="${curcontext%:*:*}:${cmd1}:"
+  elif [[ "$command[1]" = '=' ]]; then
     eval cmd1\=$command
     cmd2="$command[2,-1]"
     curcontext="${curcontext%:*:*}:${cmd2}:"
-  elif [[ "$command" == */* ]]; then
+  elif [[ "$command" = */* ]]; then
     cmd1="$command"
     cmd2="${command:t}"
     curcontext="${curcontext%:*:*}:${cmd2}:"
@@ -50,15 +53,17 @@ if [[ "$_compskip" != (all|*patterns*) ]]; then
       return ret
     fi
   done
-  for i in "${(@)_patcomps[(K)$cmd2]}"; do
-    "$i" && ret=0
-    if [[ "$_compskip" = *patterns* ]]; then
-      break
-    elif [[ "$_compskip" = all ]]; then
-      _compskip=''
-      return ret
-    fi
-  done
+  if [[ -n "$cmd2" ]]; then
+    for i in "${(@)_patcomps[(K)$cmd2]}"; do
+      "$i" && ret=0
+      if [[ "$_compskip" = *patterns* ]]; then
+        break
+      elif [[ "$_compskip" = all ]]; then
+        _compskip=''
+        return ret
+      fi
+    done
+  fi
 fi
 
 # Now look up the two names in the normal completion array.
@@ -90,16 +95,18 @@ if [[ "$_compskip" != (all|*patterns*) ]]; then
       return ret
     fi
   done
-  for i in "${(@)_postpatcomps[(K)$cmd2]}"; do
-    _compskip=default
-    "$i" && ret=0
-    if [[ "$_compskip" = *patterns* ]]; then
-      break
-    elif [[ "$_compskip" = all ]]; then
-      _compskip=''
-      return ret
-    fi
-  done
+  if [[ -n "$cmd2" ]]; then
+    for i in "${(@)_postpatcomps[(K)$cmd2]}"; do
+      _compskip=default
+      "$i" && ret=0
+      if [[ "$_compskip" = *patterns* ]]; then
+        break
+      elif [[ "$_compskip" = all ]]; then
+        _compskip=''
+        return ret
+      fi
+    done
+  fi
 fi
 
 [[ "$name" = -default- && -n "$comp" && "$_compskip" != (all|*default*) ]] &&
diff --git a/Src/Zle/compctl.c b/Src/Zle/compctl.c
index 0e1dc088c..c7356b69f 100644
--- a/Src/Zle/compctl.c
+++ b/Src/Zle/compctl.c
@@ -2469,7 +2469,7 @@ makecomplistcmd(char *os, int incmd, int flags)
     return ret;
 }
 
-/* This add the matches for the pattern compctls. */
+/* This adds the matches for the pattern compctls. */
 
 /**/
 static int
@@ -2477,9 +2477,12 @@ makecomplistpc(char *os, int incmd)
 {
     Patcomp pc;
     Patprog pat;
-    char *s = findcmd(cmdstr, 1);
+    char *s;
     int ret = 0;
 
+    s = ((shfunctab->getnode(shfunctab, cmdstr) ||
+	  builtintab->getnode(builtintab, cmdstr)) ? NULL : findcmd(cmdstr, 1));
+
     for (pc = patcomps; pc; pc = pc->next) {
 	if ((pat = patcompile(pc->pat, PAT_STATIC, NULL)) &&
 	    (pattry(pat, cmdstr) ||