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): reduce the number of moving variables ...
details: https://anonhg.NetBSD.org/src/rev/bbcde1b8fcd9
branches: trunk
changeset: 936716:bbcde1b8fcd9
user: rillig <rillig%NetBSD.org@localhost>
date: Sun Aug 02 09:54:44 2020 +0000
description:
make(1): reduce the number of moving variables in ParseModifierPart
Having only the p walk through the string is easier to understand than
assigning between p and cp2 (with its unexpressive name).
diffstat:
usr.bin/make/var.c | 28 ++++++++++++++--------------
1 files changed, 14 insertions(+), 14 deletions(-)
diffs (67 lines):
diff -r c04805608940 -r bbcde1b8fcd9 usr.bin/make/var.c
--- a/usr.bin/make/var.c Sun Aug 02 09:43:22 2020 +0000
+++ b/usr.bin/make/var.c Sun Aug 02 09:54:44 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: var.c,v 1.392 2020/08/02 09:43:22 rillig Exp $ */
+/* $NetBSD: var.c,v 1.393 2020/08/02 09:54:44 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.392 2020/08/02 09:43:22 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.393 2020/08/02 09:54:44 rillig Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)var.c 8.3 (Berkeley) 3/19/94";
#else
-__RCSID("$NetBSD: var.c,v 1.392 2020/08/02 09:43:22 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.393 2020/08/02 09:54:44 rillig Exp $");
#endif
#endif /* not lint */
#endif
@@ -1798,29 +1798,29 @@
continue;
}
- const char *cp2 = &p[1]; /* Nested variable, only parsed */
- if (*cp2 == PROPEN || *cp2 == BROPEN) {
+ const char *varstart = p; /* Nested variable, only parsed */
+ if (p[1] == PROPEN || p[1] == BROPEN) {
/*
* Find the end of this variable reference
* and suck it in without further ado.
* It will be interpreted later.
*/
- int have = *cp2;
- int want = *cp2 == PROPEN ? PRCLOSE : BRCLOSE;
+ int have = p[1];
+ int want = have == PROPEN ? PRCLOSE : BRCLOSE;
int depth = 1;
- for (++cp2; *cp2 != '\0' && depth > 0; ++cp2) {
- if (cp2[-1] != '\\') {
- if (*cp2 == have)
+ for (p += 2; *p != '\0' && depth > 0; ++p) {
+ if (p[-1] != '\\') {
+ if (*p == have)
++depth;
- if (*cp2 == want)
+ if (*p == want)
--depth;
}
}
- Buf_AddBytesBetween(&buf, p, cp2);
- p = --cp2;
+ Buf_AddBytesBetween(&buf, varstart, p);
+ p--;
} else
- Buf_AddByte(&buf, *p);
+ Buf_AddByte(&buf, *varstart);
}
if (*p != delim) {
Home |
Main Index |
Thread Index |
Old Index