zsh-workers
 help / color / mirror / code / Atom feed
* Tiny optimization to arrdup_max()
@ 2016-11-14 18:47 Bart Schaefer
  0 siblings, 0 replies; only message in thread
From: Bart Schaefer @ 2016-11-14 18:47 UTC (permalink / raw)
  To: zsh-workers

No need for arrlen() if we're just truncating.

diff --git a/Src/utils.c b/Src/utils.c
index cceaf4c..52201a9 100644
--- a/Src/utils.c
+++ b/Src/utils.c
@@ -4244,9 +4244,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)


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2016-11-14 18:47 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-14 18:47 Tiny optimization to arrdup_max() Bart Schaefer

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).