Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[PATCH 3/3] Constify two local variables.
- X-seq: zsh-workers 37253
- From: Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: [PATCH 3/3] Constify two local variables.
- Date: Mon, 30 Nov 2015 03:21:53 +0000
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= daniel.shahaf.name; h=content-type:date:from:message-id :mime-version:subject:to:x-sasl-enc:x-sasl-enc; s=mesmtp; bh=HD2 Bcp2k6Rxe9GGCvGM2t+CfzD4=; b=uhr//ke7XDN9/rn+GHZVleE5usqDt/bQua1 nOXlqDRwHHODw3MxSRnoDAn+7oRTsHZUj04wg0qM52/KetyauvUE4mxRnAugtDj0 IEj9GCBqYX2nkhcmgxaiGlvv89BvI4pIa9/buyJTnK1aRYfW7VupZdNzObYt201w qU+2MV7k=
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:message-id :mime-version:subject:to:x-sasl-enc:x-sasl-enc; s=smtpout; bh=HD 2Bcp2k6Rxe9GGCvGM2t+CfzD4=; b=dvMprD/GuSgKxJGlI+OhOcpjFGleO2kKS5 9bxI6fS+/DOBNa0SmDfx3Dpqq9t1OB9jq+Drs5sRwSMNPAVNTMoHoYJ1isFHcaC5 5p9P3LlorEb+oE+jwI6Ybl8y0rvgwEQYaqJPle20BgKpQxKH3mx+c1CToEOKQDyv tYrFs3DcQ=
- 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
---
I assume that v->pm->gsu.a->getfn() has no access to v->start and v->end, hence
changing the order is safe.
Are there any compilers that choke on 'char **const' (const pointer to pointer
to char)?
Cheers,
Daniel
Src/params.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/Src/params.c b/Src/params.c
index d8bf83d..142697f 100644
--- a/Src/params.c
+++ b/Src/params.c
@@ -2552,18 +2552,20 @@ setarrvalue(Value v, char **val)
v->pm->node.nam);
return;
} else {
- char **old, **new, **p, **q, **r;
- int pre_assignment_length;
+ char **const old = v->pm->gsu.a->getfn(v->pm);
+ char **new;
+ char **p, **q, **r; /* index variables */
+ const int pre_assignment_length = arrlen(old);
int post_assignment_length;
int i;
+ q = old;
+
if ((v->flags & VALFLAG_INV) && unset(KSHARRAYS)) {
if (v->start > 0)
v->start--;
v->end--;
}
- q = old = v->pm->gsu.a->getfn(v->pm);
- pre_assignment_length = arrlen(old);
if (v->start < 0) {
v->start += pre_assignment_length;
if (v->start < 0)
--
2.1.4
Messages sorted by:
Reverse Date,
Date,
Thread,
Author