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): inline Lst_ForEachUntil in Targ_PrintN...



details:   https://anonhg.NetBSD.org/src/rev/9e731c3bbb4c
branches:  trunk
changeset: 939424:9e731c3bbb4c
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Sep 27 11:53:03 2020 +0000

description:
make(1): inline Lst_ForEachUntil in Targ_PrintNodes

Printing a node does not modify the structure of the node, therefore the
additional housekeeping of Lst_ForEachUntil is not needed here.

Inlining the callback function also removes a lot of pointer stuff that
is more difficult to read than necessary.

diffstat:

 usr.bin/make/targ.c |  22 ++++++++++------------
 1 files changed, 10 insertions(+), 12 deletions(-)

diffs (67 lines):

diff -r 899d5eb0dea3 -r 9e731c3bbb4c usr.bin/make/targ.c
--- a/usr.bin/make/targ.c       Sun Sep 27 11:43:46 2020 +0000
+++ b/usr.bin/make/targ.c       Sun Sep 27 11:53:03 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: targ.c,v 1.103 2020/09/27 01:07:12 mrg Exp $   */
+/*     $NetBSD: targ.c,v 1.104 2020/09/27 11:53:03 rillig Exp $        */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -121,7 +121,7 @@
 #include         "dir.h"
 
 /*     "@(#)targ.c     8.2 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: targ.c,v 1.103 2020/09/27 01:07:12 mrg Exp $");
+MAKE_RCSID("$NetBSD: targ.c,v 1.104 2020/09/27 11:53:03 rillig Exp $");
 
 static GNodeList *allTargets;  /* the list of all targets found so far */
 #ifdef CLEANUP
@@ -435,16 +435,13 @@
     }
 }
 
-static int
-PrintNode(void *gnp, void *passp)
+static void
+PrintNode(GNode *gn, int pass)
 {
-    GNode *gn = gnp;
-    int pass = *(const int *)passp;
-
     fprintf(debug_file, "# %s%s", gn->name, gn->cohort_num);
     GNode_FprintDetails(debug_file, ", ", gn, "\n");
     if (gn->flags == 0)
-       return 0;
+       return;
 
     if (!OP_NOP(gn->type)) {
        fprintf(debug_file, "#\n");
@@ -493,23 +490,24 @@
        Targ_PrintCmds(gn);
        fprintf(debug_file, "\n\n");
        if (gn->type & OP_DOUBLEDEP) {
-           Lst_ForEachUntil(gn->cohorts, PrintNode, passp);
+           Targ_PrintNodes(gn->cohorts, pass);
        }
     }
-    return 0;
 }
 
 /* Print the contents of a node. */
 void
 Targ_PrintNode(GNode *gn, int pass)
 {
-    PrintNode(gn, &pass);
+    PrintNode(gn, pass);
 }
 
 void
 Targ_PrintNodes(GNodeList *gnodes, int pass)
 {
-    Lst_ForEachUntil(gnodes, PrintNode, &pass);
+    GNodeListNode *ln;
+    for (ln = gnodes->first; ln != NULL; ln = ln->next)
+       PrintNode(ln->datum, pass);
 }
 
 /* Print only those targets that are just a source. */



Home | Main Index | Thread Index | Old Index