Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Tiny optimization to arrdup_max()
- X-seq: zsh-workers 39943
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: Tiny optimization to arrdup_max()
- Date: Mon, 14 Nov 2016 10:47:43 -0800
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=from:message-id:date:to:subject:mime-version; bh=JbW8aRsun5YxOiyUMXxAbPqaxplegfh0NQfCqF/tpWU=; b=F7oTxUSDq+XKXMrFCwRjcqUgrw+5LsI1pR3Uq94Mk3wq7EoChnMvaak+oxXJ3x042F YEPKx81zJoWueIv3MrAynK4tLB7vEEKu3dOlMtsyC2gRVp/47YQywV1rb2T5DGtTF5Hu R3ngLhoFWoWczYYFQCIhgCo1DWV3lD9QSws+hXn9XVHpUTYYWnuIpcqfKpdHIVEPkk21 04NpD4mZlm/AZ9DVgRzni11ckzFXHd6bLfkkJ/CAQgCuaskY1YiamvTqelRgFe3K+L7i 6XYBTRQFKKPiDsvRi2bA3apv8mpr0l6PlMoDqzMYH295Sh0LHZ52Fd+YLhj5sAb2fEYx cE4g==
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
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)
Messages sorted by:
Reverse Date,
Date,
Thread,
Author