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): only ask for newline if :Q actually ne...



details:   https://anonhg.NetBSD.org/src/rev/ba33304d3819
branches:  trunk
changeset: 974059:ba33304d3819
user:      rillig <rillig%NetBSD.org@localhost>
date:      Tue Jul 21 21:32:55 2020 +0000

description:
make(1): only ask for newline if :Q actually needs it

This simple change reduces the binary size of var.o by 96 bytes (Clang,
x86_64). Given that the code is still the same, just in a different
order, this is a bit surprising.

diffstat:

 usr.bin/make/var.c |  20 ++++++++------------
 1 files changed, 8 insertions(+), 12 deletions(-)

diffs (51 lines):

diff -r 2f1de0dd9c8a -r ba33304d3819 usr.bin/make/var.c
--- a/usr.bin/make/var.c        Tue Jul 21 21:13:24 2020 +0000
+++ b/usr.bin/make/var.c        Tue Jul 21 21:32:55 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: var.c,v 1.292 2020/07/21 21:13:24 rillig Exp $ */
+/*     $NetBSD: var.c,v 1.293 2020/07/21 21:32:55 rillig Exp $ */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.292 2020/07/21 21:13:24 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.293 2020/07/21 21:32:55 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.292 2020/07/21 21:13:24 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.293 2020/07/21 21:32:55 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -1971,19 +1971,15 @@
 static char *
 VarQuote(char *str, Boolean quoteDollar)
 {
-    Buffer       buf;
-    const char *newline;
-    size_t nlen;
-
-    if ((newline = Shell_GetNewline()) == NULL)
-       newline = "\\\n";
-    nlen = strlen(newline);
-
+    Buffer buf;
     Buf_Init(&buf, 0);
 
     for (; *str != '\0'; str++) {
        if (*str == '\n') {
-           Buf_AddBytes(&buf, nlen, newline);
+           const char *newline = Shell_GetNewline();
+           if (newline == NULL)
+               newline = "\\\n";
+           Buf_AddBytes(&buf, strlen(newline), newline);
            continue;
        }
        if (isspace((unsigned char)*str) || ismeta((unsigned char)*str))



Home | Main Index | Thread Index | Old Index