zsh-workers
 help / color / mirror / code / Atom feed
* [PATCH 3/3] Constify two local variables.
@ 2015-11-30  3:21 Daniel Shahaf
  2015-11-30  9:38 ` Peter Stephenson
  0 siblings, 1 reply; 11+ messages in thread
From: Daniel Shahaf @ 2015-11-30  3:21 UTC (permalink / raw)
  To: zsh-workers

---
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


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2015-12-04  0:36 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-30  3:21 [PATCH 3/3] Constify two local variables Daniel Shahaf
2015-11-30  9:38 ` Peter Stephenson
2015-11-30 15:59   ` Daniel Shahaf
2015-11-30 16:28     ` Bart Schaefer
2015-11-30 16:42     ` Peter Stephenson
2015-11-30 20:39       ` Bart Schaefer
2015-11-30 21:36         ` Bart Schaefer
2015-12-02  0:36         ` Daniel Shahaf
2015-12-02  1:11           ` Bart Schaefer
2015-12-03 23:37             ` Daniel Shahaf
2015-12-04  0:36               ` 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).