make: skip memcpy when parsing but not evaluating ':D' and ':U'

No functional change, just a tiny bit of performance improvement,
probably not even measurable.  Having the code nevertheless serves as a
copy-and-paste template for implementing other modifiers that might
perform more costly tasks.
This commit is contained in:
rillig 2021-03-14 18:08:25 +00:00
parent a1747f17a6
commit ae0a762a50

View File

@ -1,4 +1,4 @@
/* $NetBSD: var.c,v 1.870 2021/03/14 18:02:44 rillig Exp $ */
/* $NetBSD: var.c,v 1.871 2021/03/14 18:08:25 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.870 2021/03/14 18:02:44 rillig Exp $");
MAKE_RCSID("$NetBSD: var.c,v 1.871 2021/03/14 18:08:25 rillig Exp $");
typedef enum VarFlags {
VFL_NONE = 0,
@ -2488,7 +2488,8 @@ ApplyModifier_Defined(const char **pp, ApplyModifiersState *st)
(void)Var_Parse(&p, expr->scope, eflags, &nested_val);
/* TODO: handle errors */
Buf_AddStr(&buf, nested_val.str);
if (expr->eflags & VARE_WANTRES)
Buf_AddStr(&buf, nested_val.str);
FStr_Done(&nested_val);
continue;
}