Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/make make(1): inline variable in ForReadMore



details:   https://anonhg.NetBSD.org/src/rev/4f63b5c37122
branches:  trunk
changeset: 1017549:4f63b5c37122
user:      rillig <rillig%NetBSD.org@localhost>
date:      Thu Dec 31 03:33:10 2020 +0000

description:
make(1): inline variable in ForReadMore

This variable was intended to help the compilers produce efficient code
by avoiding a duplicate memory read.  As it turned out, GCC 5.5 doesn't
need this help, and probably newer compilers don't need it either.  Well
done, GCC, keeping track of the memory locations even if the pointer to
it changes in the middle.

diffstat:

 usr.bin/make/for.c |  11 +++++------
 1 files changed, 5 insertions(+), 6 deletions(-)

diffs (33 lines):

diff -r 319b25f9a61c -r 4f63b5c37122 usr.bin/make/for.c
--- a/usr.bin/make/for.c        Thu Dec 31 03:19:00 2020 +0000
+++ b/usr.bin/make/for.c        Thu Dec 31 03:33:10 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: for.c,v 1.125 2020/12/31 03:19:00 rillig Exp $ */
+/*     $NetBSD: for.c,v 1.126 2020/12/31 03:33:10 rillig Exp $ */
 
 /*
  * Copyright (c) 1992, The Regents of the University of California.
@@ -58,7 +58,7 @@
 #include "make.h"
 
 /*     "@(#)for.c      8.1 (Berkeley) 6/6/93"  */
-MAKE_RCSID("$NetBSD: for.c,v 1.125 2020/12/31 03:19:00 rillig Exp $");
+MAKE_RCSID("$NetBSD: for.c,v 1.126 2020/12/31 03:33:10 rillig Exp $");
 
 static int forLevel = 0;       /* Nesting level */
 
@@ -459,11 +459,10 @@
        mark = Buf_GetAll(&f->body, NULL);
        body_end = mark + Buf_Len(&f->body);
        for (p = mark; (p = strchr(p, '$')) != NULL;) {
-               char ch = p[1];
-               if (ch == '{' || ch == '(') {
+               if (p[1] == '{' || p[1] == '(') {
                        p += 2;
-                       SubstVarLong(f, &p, &mark, ch == '{' ? '}' : ')');
-               } else if (ch != '\0') {
+                       SubstVarLong(f, &p, &mark, p[-1] == '{' ? '}' : ')');
+               } else if (p[1] != '\0') {
                        p++;
                        SubstVarShort(f, &p, &mark);
                } else



Home | Main Index | Thread Index | Old Index