about summary refs log tree commit diff
diff options
context:
space:
mode:
authorBarton E. Schaefer <schaefer@zsh.org>2016-11-14 14:44:57 -0800
committerBarton E. Schaefer <schaefer@zsh.org>2016-11-15 10:04:14 -0800
commit98b7960c78ef720c3d830bef2258f6aa86c055de (patch)
treecddab57633ba88681785aeff0afbbb2a2dd6d306
parent921b39ac6b25dbfcc477fc7db4ed1c5c3ffb778c (diff)
downloadzsh-98b7960c78ef720c3d830bef2258f6aa86c055de.tar.gz
zsh-98b7960c78ef720c3d830bef2258f6aa86c055de.tar.xz
zsh-98b7960c78ef720c3d830bef2258f6aa86c055de.zip
39943: no need to compute arrlen() in arrdup_max() when max == 0.
-rw-r--r--ChangeLog5
-rw-r--r--Src/utils.c5
2 files changed, 8 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 0040c2367..488f1ed45 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -7,6 +7,11 @@
 	* 39947: Test/D04parameter.ztst: Test out-of-rantge multiple
 	array subscripts with and without (@).
 
+2016-11-14  Barton E. Schaefer  <schaefer@zsh.org>
+
+	* 39943: Src/utils.c: no need to compute arrlen() in arrdup_max()
+	when max == 0.
+
 2016-11-15  Jun-ichi Takimoto <takimoto-j@kba.biglobe.ne.jp>
 
 	* 39937: Src/params.c: fix a problem introduced by 39886.
diff --git a/Src/utils.c b/Src/utils.c
index 92d831172..151e9e4eb 100644
--- a/Src/utils.c
+++ b/Src/utils.c
@@ -4252,9 +4252,10 @@ mod_export char **
 arrdup_max(char **s, unsigned max)
 {
     char **x, **y, **send;
-    int len;
+    int len = 0;
 
-    len = arrlen(s);
+    if (max)
+	len = arrlen(s);
 
     /* Limit has sense only if not equal to len */
     if (max > len)