Module Name:    src
Committed By:   rillig
Date:           Sun Mar 14 20:18:33 UTC 2021

Modified Files:
        src/usr.bin/make: var.c

Log Message:
make: skip variable lookup for '::=' modifiers in parse-only mode

This is just to keep the code consistent among the various variable
modifiers.  The performance gain is negligible.

The actual assignment to the variable had already been skipped
previously.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.881 -r1.882 src/usr.bin/make/var.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.881 src/usr.bin/make/var.c:1.882
--- src/usr.bin/make/var.c:1.881	Sun Mar 14 20:12:16 2021
+++ src/usr.bin/make/var.c	Sun Mar 14 20:18:33 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.881 2021/03/14 20:12:16 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.882 2021/03/14 20:18:33 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -140,7 +140,7 @@
 #include "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.881 2021/03/14 20:12:16 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.882 2021/03/14 20:18:33 rillig Exp $");
 
 typedef enum VarFlags {
 	VFL_NONE	= 0,
@@ -3404,6 +3404,9 @@ ok:
 
 	(*pp)--;		/* Go back to the st->endc. */
 
+	if (!(expr->eflags & VARE_WANTRES))
+		goto done;
+
 	scope = expr->scope;	/* scope where v belongs */
 	if (expr->defined == DEF_REGULAR && expr->scope != SCOPE_GLOBAL) {
 		Var *gv = VarFind(expr->var->name.str, expr->scope, FALSE);
@@ -3414,33 +3417,32 @@ ok:
 	}
 
 	/* XXX: Expanding the variable name at this point sounds wrong. */
-	if (expr->eflags & VARE_WANTRES) {
-		switch (op[0]) {
-		case '+':
-			Var_AppendExpand(scope, expr->var->name.str, val);
-			break;
-		case '!': {
-			const char *errfmt;
-			char *cmd_output = Cmd_Exec(val, &errfmt);
-			if (errfmt != NULL)
-				Error(errfmt, val);
-			else
-				Var_SetExpand(scope,
-				    expr->var->name.str, cmd_output);
-			free(cmd_output);
-			break;
-		}
-		case '?':
-			if (expr->defined == DEF_REGULAR)
-				break;
-			/* FALLTHROUGH */
-		default:
-			Var_SetExpand(scope, expr->var->name.str, val);
+	switch (op[0]) {
+	case '+':
+		Var_AppendExpand(scope, expr->var->name.str, val);
+		break;
+	case '!': {
+		const char *errfmt;
+		char *cmd_output = Cmd_Exec(val, &errfmt);
+		if (errfmt != NULL)
+			Error(errfmt, val);
+		else
+			Var_SetExpand(scope, expr->var->name.str, cmd_output);
+		free(cmd_output);
+		break;
+	}
+	case '?':
+		if (expr->defined == DEF_REGULAR)
 			break;
-		}
+		/* FALLTHROUGH */
+	default:
+		Var_SetExpand(scope, expr->var->name.str, val);
+		break;
 	}
-	free(val);
 	Expr_SetValueRefer(expr, "");
+
+done:
+	free(val);
 	return AMR_OK;
 }
 

Reply via email to