summary refs log tree commit diff
diff options
context:
space:
mode:
authorSven Wischnowsky <wischnow@users.sourceforge.net>2000-04-26 06:45:50 +0000
committerSven Wischnowsky <wischnow@users.sourceforge.net>2000-04-26 06:45:50 +0000
commit9ecbacab6b041c12f2dd3eb1f78ba69ccbff100d (patch)
treeed1aa75b3b0e7025be51a016a82b5c358d816538
parent67fd3b73cad16982b754aa4289516819775932b7 (diff)
downloadzsh-9ecbacab6b041c12f2dd3eb1f78ba69ccbff100d.tar.gz
zsh-9ecbacab6b041c12f2dd3eb1f78ba69ccbff100d.tar.xz
zsh-9ecbacab6b041c12f2dd3eb1f78ba69ccbff100d.zip
faster test for `*'-patterns in matching control; prefer direct character matches over match specs in recursive invocations of match_str() (10925)
-rw-r--r--ChangeLog4
-rw-r--r--Src/Zle/compmatch.c42
2 files changed, 42 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index e961ca5ef..6ff62d907 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2000-04-26  Sven Wischnowsky  <wischnow@informatik.hu-berlin.de>
 
+	* 10925: Src/Zle/compmatch.c: faster test for `*'-patterns in
+ 	matching control; prefer direct character matches over match specs
+ 	in recursive invocations of match_str()
+	
 	* 10924: Src/Zle/compmatch.c: fix for matching control; improve
  	merging cline lists
 	
diff --git a/Src/Zle/compmatch.c b/Src/Zle/compmatch.c
index a4aea2963..24f482669 100644
--- a/Src/Zle/compmatch.c
+++ b/Src/Zle/compmatch.c
@@ -469,7 +469,39 @@ match_str(char *l, char *w, Brinfo *bpp, int bc, int *rwlp,
 	bp = bp->next;
     }
     while (ll && lw) {
-	/* First try the matchers. */
+
+	/* Hm, we unconditionally first tried the matchers for the cases
+	 * where the beginnings of the line and word patterns match the
+	 * same character(s).
+	 * But first testing if the characters are the same is sooo
+	 * much faster...
+	 * Maybe it's OK to make same-character matching be preferred in
+	 * recursive calls. At least, it /seems/ to work.
+	 *
+	 * Let's try.
+	 */
+
+	bslash = 0;
+	if (test && (l[ind] == w[ind] ||
+		     (bslash = (lw > 1 && w[ind] == '\\' &&
+				(ind ? (w[0] == l[0]) : (w[1] == l[0])))))) {
+	    /* No matcher could be used, but the strings have the same
+	     * character here, skip over it. */
+	    l += add; w += (bslash ? (add + add ) : add);
+	    il++; iw += 1 + bslash;
+	    ll--; lw -= 1 + bslash;
+	    bc++;
+	    if (!test)
+		while (bp && bc >= (useqbr ? bp->qpos : bp->pos)) {
+		    bp->curpos = matchbufadded + (sfx ? (ow - w) : (w - ow)) + obc;
+		    bp = bp->next;
+		}
+	    lm = NULL;
+	    he = 0;
+
+	    continue;
+	}
+	/* First try the matchers. Err... see above. */
 	for (mp = NULL, ms = mstack; !mp && ms; ms = ms->next) {
 	    for (mp = ms->matcher; mp; mp = mp->next) {
 		t = 1;
@@ -737,10 +769,12 @@ match_str(char *l, char *w, Brinfo *bpp, int bc, int *rwlp,
 	if (mp)
 	    continue;
 
+	/* Same code as at the beginning, used in top-level calls. */
+
 	bslash = 0;
-	if (l[ind] == w[ind] ||
-	    (bslash = (lw > 1 && w[ind] == '\\' &&
-		       (ind ? (w[0] == l[0]) : (w[1] == l[0]))))) {
+	if (!test && (l[ind] == w[ind] ||
+		      (bslash = (lw > 1 && w[ind] == '\\' &&
+				 (ind ? (w[0] == l[0]) : (w[1] == l[0])))))) {
 	    /* No matcher could be used, but the strings have the same
 	     * character here, skip over it. */
 	    l += add; w += (bslash ? (add + add ) : add);