about summary refs log tree commit diff
diff options
context:
space:
mode:
authorSebastian Gniazdowski <psprint@zdharma.org>2017-07-05 09:35:57 +0200
committerPeter Stephenson <p.w.stephenson@ntlworld.com>2017-07-09 17:38:01 +0100
commitb31f947795fe9711d6094bbfc4675f60b8ffc746 (patch)
tree20c3d5dfabc067524feea5b410052cd6d81483d1
parente556f9c78d0216c2a543035586bc3a7cd1918d73 (diff)
downloadzsh-b31f947795fe9711d6094bbfc4675f60b8ffc746.tar.gz
zsh-b31f947795fe9711d6094bbfc4675f60b8ffc746.tar.xz
zsh-b31f947795fe9711d6094bbfc4675f60b8ffc746.zip
41402: Delay has_tokens() in ecstrcode as may not be needed
-rw-r--r--ChangeLog3
-rw-r--r--Src/parse.c6
2 files changed, 8 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index b3e702cd1..ab99306be 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2017-07-09  Peter Stephenson  <p.w.stephenson@ntlworld.com>
 
+	* Sebastian: 41402: Src/parse.c: Delay checking tokens in
+	ecstrcode() as may not be needed.
+
 	* Sebastian: 41402: Src/parse.c, Src/zsh.h: Add hasher to
 	ecstrcode() to reduce string comparisons.
 
diff --git a/Src/parse.c b/Src/parse.c
index 00a8f6a5a..ba9cd61eb 100644
--- a/Src/parse.c
+++ b/Src/parse.c
@@ -394,11 +394,12 @@ ecdel(int p)
 static wordcode
 ecstrcode(char *s)
 {
-    int l, t = has_token(s);
+    int l, t;
 
     unsigned val = hasher(s);
 
     if ((l = strlen(s) + 1) && l <= 4) {
+	t = has_token(s);
 	wordcode c = (t ? 3 : 2);
 	switch (l) {
 	case 4: c |= ((wordcode) STOUC(s[2])) << 19;
@@ -417,6 +418,9 @@ ecstrcode(char *s)
             }
 	    pp = (cmp < 0 ? &(p->left) : &(p->right));
 	}
+
+        t = has_token(s);
+
 	p = *pp = (Eccstr) zhalloc(sizeof(*p));
 	p->left = p->right = 0;
 	p->offs = ((ecsoffs - ecssub) << 2) | (t ? 1 : 0);