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: skip variable lookup for '::=' modifiers ...



details:   https://anonhg.NetBSD.org/src/rev/76b01d19fe8b
branches:  trunk
changeset: 981558:76b01d19fe8b
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Mar 14 20:18:33 2021 +0000

description:
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.

diffstat:

 usr.bin/make/var.c |  54 ++++++++++++++++++++++++++++--------------------------
 1 files changed, 28 insertions(+), 26 deletions(-)

diffs (85 lines):

diff -r 3f3e73763483 -r 76b01d19fe8b usr.bin/make/var.c
--- a/usr.bin/make/var.c        Sun Mar 14 20:12:16 2021 +0000
+++ b/usr.bin/make/var.c        Sun Mar 14 20:18:33 2021 +0000
@@ -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 @@
 
        (*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 @@
        }
 
        /* 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);
+       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;
-               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;
-               }
+               /* FALLTHROUGH */
+       default:
+               Var_SetExpand(scope, expr->var->name.str, val);
+               break;
        }
+       Expr_SetValueRefer(expr, "");
+
+done:
        free(val);
-       Expr_SetValueRefer(expr, "");
        return AMR_OK;
 }
 



Home | Main Index | Thread Index | Old Index