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 code size in :D and :U modifier



details:   https://anonhg.NetBSD.org/src/rev/0f0d45cc38f4
branches:  trunk
changeset: 1012672:0f0d45cc38f4
user:      rillig <rillig%NetBSD.org@localhost>
date:      Thu Aug 06 17:48:41 2020 +0000

description:
make(1): reduce code size in :D and :U modifier

This affects both the source code size and the binary code size, at
least on x86_64.

diffstat:

 usr.bin/make/var.c |  25 +++++++++----------------
 1 files changed, 9 insertions(+), 16 deletions(-)

diffs (67 lines):

diff -r 703ba2ad35bf -r 0f0d45cc38f4 usr.bin/make/var.c
--- a/usr.bin/make/var.c        Thu Aug 06 17:32:40 2020 +0000
+++ b/usr.bin/make/var.c        Thu Aug 06 17:48:41 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: var.c,v 1.414 2020/08/06 17:32:40 rillig Exp $ */
+/*     $NetBSD: var.c,v 1.415 2020/08/06 17:48:41 rillig Exp $ */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.414 2020/08/06 17:32:40 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.415 2020/08/06 17:48:41 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.414 2020/08/06 17:32:40 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.415 2020/08/06 17:48:41 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -1999,18 +1999,11 @@
     Buffer buf;                        /* Buffer for patterns */
     const char *p;
 
-    VarEvalFlags neflags;
+    VarEvalFlags eflags = st->eflags & ~VARE_WANTRES;
     if (st->eflags & VARE_WANTRES) {
-       Boolean wantres;
-       if (**pp == 'U')
-           wantres = (st->v->flags & VAR_JUNK) != 0;
-       else
-           wantres = (st->v->flags & VAR_JUNK) == 0;
-       neflags = st->eflags & ~VARE_WANTRES;
-       if (wantres)
-           neflags |= VARE_WANTRES;
-    } else
-       neflags = st->eflags;
+       if ((**pp == 'D') == !(st->v->flags & VAR_JUNK))
+           eflags |= VARE_WANTRES;
+    }
 
     /*
      * Pass through mod looking for 1) escaped delimiters,
@@ -2035,7 +2028,7 @@
            int     len;
            void    *freeIt;
 
-           cp2 = Var_Parse(p, st->ctxt, neflags, &len, &freeIt);
+           cp2 = Var_Parse(p, st->ctxt, eflags, &len, &freeIt);
            Buf_AddStr(&buf, cp2);
            free(freeIt);
            p += len;
@@ -2048,7 +2041,7 @@
 
     if (st->v->flags & VAR_JUNK)
        st->v->flags |= VAR_KEEP;
-    if (neflags & VARE_WANTRES) {
+    if (eflags & VARE_WANTRES) {
        st->newVal = Buf_Destroy(&buf, FALSE);
     } else {
        st->newVal = st->val;



Home | Main Index | Thread Index | Old Index