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 call to strchr in ValidShortVar...
details: https://anonhg.NetBSD.org/src/rev/021a296360e6
branches: trunk
changeset: 938671:021a296360e6
user: rillig <rillig%NetBSD.org@localhost>
date: Sun Sep 13 08:11:40 2020 +0000
description:
make(1): inline call to strchr in ValidShortVarname
It's a pity that neither GCC 5 nor GCC 10 nor Clang 9 inline this code
themselves, even though it would be easy to do.
Clang 9 at least replaces strchr with memchr, but that is still too
complicated for a simple "is this character one of these" question.
For a repeated "if (varname != ...)" instead of the switch, GCC 10
generates really boring and inefficient code, even though it is easy to
see that the order of the comparisons doesn't matter.
diffstat:
usr.bin/make/var.c | 18 +++++++++++++-----
1 files changed, 13 insertions(+), 5 deletions(-)
diffs (45 lines):
diff -r bb1736b5ae7c -r 021a296360e6 usr.bin/make/var.c
--- a/usr.bin/make/var.c Sun Sep 13 07:42:20 2020 +0000
+++ b/usr.bin/make/var.c Sun Sep 13 08:11:40 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: var.c,v 1.507 2020/09/13 07:42:20 rillig Exp $ */
+/* $NetBSD: var.c,v 1.508 2020/09/13 08:11:40 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.507 2020/09/13 07:42:20 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.508 2020/09/13 08:11:40 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.507 2020/09/13 07:42:20 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.508 2020/09/13 08:11:40 rillig Exp $");
#endif
#endif /* not lint */
#endif
@@ -3372,8 +3372,16 @@
static Boolean
ValidShortVarname(char varname, const char *start)
{
- if (varname != '\0' && strchr(")}:$", varname) == NULL)
- return TRUE;
+ switch (varname) {
+ case '\0':
+ case ')':
+ case '}':
+ case ':':
+ case '$':
+ break;
+ default:
+ return TRUE;
+ }
if (!DEBUG(LINT))
return FALSE;
Home |
Main Index |
Thread Index |
Old Index