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): save a few bytes and cycles by compari...



details:   https://anonhg.NetBSD.org/src/rev/0decf40be32d
branches:  trunk
changeset: 974239:0decf40be32d
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Jul 26 17:09:23 2020 +0000

description:
make(1): save a few bytes and cycles by comparing against 0

The comparison against ac - 1 could have been optimized by the compilers
as well, but both GCC 5 and Clang produce smaller code for the comparison
against 0.

diffstat:

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

diffs (62 lines):

diff -r 1bcbe46b66b1 -r 0decf40be32d usr.bin/make/var.c
--- a/usr.bin/make/var.c        Sun Jul 26 16:59:08 2020 +0000
+++ b/usr.bin/make/var.c        Sun Jul 26 17:09:23 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: var.c,v 1.317 2020/07/26 16:59:08 rillig Exp $ */
+/*     $NetBSD: var.c,v 1.318 2020/07/26 17:09:23 rillig Exp $ */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.317 2020/07/26 16:59:08 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.318 2020/07/26 17:09:23 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.317 2020/07/26 16:59:08 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.318 2020/07/26 17:09:23 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -1699,9 +1699,9 @@
     }
 
     for (i = 0; i < ac; i++) {
+       if (i != 0)
+           Buf_AddByte(&buf, ' ');
        Buf_AddStr(&buf, av[i]);
-       if (i != ac - 1)
-           Buf_AddByte(&buf, ' ');
     }
 
     free(as);
@@ -1746,9 +1746,9 @@
     }
 
     for (i = 0; i < ac; i++) {
+       if (i != 0)
+           Buf_AddByte(&buf, ' ');
        Buf_AddStr(&buf, av[i]);
-       if (i != ac - 1)
-           Buf_AddByte(&buf, ' ');
     }
 
     free(as);
@@ -1787,9 +1787,9 @@
        av = brk_string(str, &ac, FALSE, &as);
     }
     for (i = 0; i < ac; i++) {
+       if (i != 0)
+           Buf_AddByte(&buf, ' ');
        Buf_AddInt(&buf, 1 + i);
-       if (i != ac - 1)
-           Buf_AddByte(&buf, ' ');
     }
 
     free(as);



Home | Main Index | Thread Index | Old Index