Module Name:    src
Committed By:   rillig
Date:           Sat Nov 28 19:20:04 UTC 2020

Modified Files:
        src/usr.bin/make: compat.c make.c make.h parse.c suff.c targ.c

Log Message:
make(1): reduce pointer indirection for GNode.cohorts


To generate a diff of this commit:
cvs rdiff -u -r1.194 -r1.195 src/usr.bin/make/compat.c
cvs rdiff -u -r1.221 -r1.222 src/usr.bin/make/make.c
cvs rdiff -u -r1.223 -r1.224 src/usr.bin/make/make.h
cvs rdiff -u -r1.456 -r1.457 src/usr.bin/make/parse.c
cvs rdiff -u -r1.311 -r1.312 src/usr.bin/make/suff.c
cvs rdiff -u -r1.144 -r1.145 src/usr.bin/make/targ.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/compat.c
diff -u src/usr.bin/make/compat.c:1.194 src/usr.bin/make/compat.c:1.195
--- src/usr.bin/make/compat.c:1.194	Sat Nov 28 19:12:28 2020
+++ src/usr.bin/make/compat.c	Sat Nov 28 19:20:03 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: compat.c,v 1.194 2020/11/28 19:12:28 rillig Exp $	*/
+/*	$NetBSD: compat.c,v 1.195 2020/11/28 19:20:03 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -96,7 +96,7 @@
 #include "pathnames.h"
 
 /*	"@(#)compat.c	8.2 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: compat.c,v 1.194 2020/11/28 19:12:28 rillig Exp $");
+MAKE_RCSID("$NetBSD: compat.c,v 1.195 2020/11/28 19:20:03 rillig Exp $");
 
 static GNode *curTarg = NULL;
 static pid_t compatChild;
@@ -652,7 +652,7 @@ Compat_Make(GNode *gn, GNode *pgn)
 	}
 
 cohorts:
-	MakeNodes(gn->cohorts, pgn);
+	MakeNodes(&gn->cohorts, pgn);
 }
 
 /* Initialize this module and start making.

Index: src/usr.bin/make/make.c
diff -u src/usr.bin/make/make.c:1.221 src/usr.bin/make/make.c:1.222
--- src/usr.bin/make/make.c:1.221	Sat Nov 28 19:16:53 2020
+++ src/usr.bin/make/make.c	Sat Nov 28 19:20:03 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: make.c,v 1.221 2020/11/28 19:16:53 rillig Exp $	*/
+/*	$NetBSD: make.c,v 1.222 2020/11/28 19:20:03 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -102,7 +102,7 @@
 #include "job.h"
 
 /*	"@(#)make.c	8.1 (Berkeley) 6/6/93"	*/
-MAKE_RCSID("$NetBSD: make.c,v 1.221 2020/11/28 19:16:53 rillig Exp $");
+MAKE_RCSID("$NetBSD: make.c,v 1.222 2020/11/28 19:20:03 rillig Exp $");
 
 /* Sequence # to detect recursion. */
 static unsigned int checked_seqno = 1;
@@ -890,7 +890,7 @@ MakeBuildChild(GNode *cn, GNodeListNode 
 	if (cn->unmade_cohorts != 0) {
 		ListNode *ln;
 
-		for (ln = cn->cohorts->first; ln != NULL; ln = ln->next)
+		for (ln = cn->cohorts.first; ln != NULL; ln = ln->next)
 			if (MakeBuildChild(ln->datum, toBeMadeNext) != 0)
 				break;
 	}
@@ -1163,7 +1163,7 @@ Make_ExpandUse(GNodeList *targs)
 	       gn->name, gn->cohort_num);
 
 	if (gn->type & OP_DOUBLEDEP)
-	    Lst_PrependAll(examine, gn->cohorts);
+	    Lst_PrependAll(examine, &gn->cohorts);
 
 	/*
 	 * Apply any .USE rules before looking for implicit dependencies
@@ -1272,7 +1272,7 @@ Make_ProcessWait(GNodeList *targs)
 	DEBUG1(MAKE, "Make_ProcessWait: examine %s\n", pgn->name);
 
 	if (pgn->type & OP_DOUBLEDEP)
-	    Lst_PrependAll(examine, pgn->cohorts);
+	    Lst_PrependAll(examine, &pgn->cohorts);
 
 	owln = pgn->children.first;
 	for (ln = pgn->children.first; ln != NULL; ln = ln->next) {

Index: src/usr.bin/make/make.h
diff -u src/usr.bin/make/make.h:1.223 src/usr.bin/make/make.h:1.224
--- src/usr.bin/make/make.h:1.223	Sat Nov 28 19:16:53 2020
+++ src/usr.bin/make/make.h	Sat Nov 28 19:20:03 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: make.h,v 1.223 2020/11/28 19:16:53 rillig Exp $	*/
+/*	$NetBSD: make.h,v 1.224 2020/11/28 19:20:03 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -401,7 +401,7 @@ typedef struct GNode {
 	GNodeList order_succ;
 
 	/* Other nodes of the same name, for the '::' dependency operator. */
-	GNodeList *cohorts;
+	GNodeList cohorts;
 	/* The "#n" suffix for this cohort, or "" for other nodes */
 	char cohort_num[8];
 	/* The number of unmade instances on the cohorts list */

Index: src/usr.bin/make/parse.c
diff -u src/usr.bin/make/parse.c:1.456 src/usr.bin/make/parse.c:1.457
--- src/usr.bin/make/parse.c:1.456	Sat Nov 28 19:16:53 2020
+++ src/usr.bin/make/parse.c	Sat Nov 28 19:20:03 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.456 2020/11/28 19:16:53 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.457 2020/11/28 19:20:03 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -117,7 +117,7 @@
 #include "pathnames.h"
 
 /*	"@(#)parse.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: parse.c,v 1.456 2020/11/28 19:16:53 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.457 2020/11/28 19:20:03 rillig Exp $");
 
 /* types and constants */
 
@@ -758,8 +758,8 @@ ParseMessage(const char *directive)
 static void
 LinkSource(GNode *pgn, GNode *cgn, Boolean isSpecial)
 {
-    if ((pgn->type & OP_DOUBLEDEP) && !Lst_IsEmpty(pgn->cohorts))
-	pgn = pgn->cohorts->last->datum;
+    if ((pgn->type & OP_DOUBLEDEP) && !Lst_IsEmpty(&pgn->cohorts))
+	pgn = pgn->cohorts.last->datum;
 
     Lst_Append(&pgn->children, cgn);
     pgn->unmade++;
@@ -830,7 +830,7 @@ TryApplyDependencyOperator(GNode *gn, GN
 	 * traversals will no longer see this node anyway. -mycroft)
 	 */
 	cohort->type = op | OP_INVISIBLE;
-	Lst_Append(gn->cohorts, cohort);
+	Lst_Append(&gn->cohorts, cohort);
 	cohort->centurion = gn;
 	gn->unmade_cohorts++;
 	snprintf(cohort->cohort_num, sizeof cohort->cohort_num, "#%d",
@@ -2055,8 +2055,8 @@ static void
 ParseAddCmd(GNode *gn, char *cmd)
 {
     /* Add to last (ie current) cohort for :: targets */
-    if ((gn->type & OP_DOUBLEDEP) && gn->cohorts->last != NULL)
-	gn = gn->cohorts->last->datum;
+    if ((gn->type & OP_DOUBLEDEP) && gn->cohorts.last != NULL)
+	gn = gn->cohorts.last->datum;
 
     /* if target already supplied, ignore commands */
     if (!(gn->type & OP_HAS_COMMANDS)) {
@@ -3152,7 +3152,7 @@ Parse_MainName(void)
 
     if (mainNode->type & OP_DOUBLEDEP) {
 	Lst_Append(mainList, mainNode);
-	Lst_AppendAll(mainList, mainNode->cohorts);
+	Lst_AppendAll(mainList, &mainNode->cohorts);
     } else
 	Lst_Append(mainList, mainNode);
 

Index: src/usr.bin/make/suff.c
diff -u src/usr.bin/make/suff.c:1.311 src/usr.bin/make/suff.c:1.312
--- src/usr.bin/make/suff.c:1.311	Sat Nov 28 19:16:53 2020
+++ src/usr.bin/make/suff.c	Sat Nov 28 19:20:03 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: suff.c,v 1.311 2020/11/28 19:16:53 rillig Exp $	*/
+/*	$NetBSD: suff.c,v 1.312 2020/11/28 19:20:03 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -114,7 +114,7 @@
 #include "dir.h"
 
 /*	"@(#)suff.c	8.4 (Berkeley) 3/21/94"	*/
-MAKE_RCSID("$NetBSD: suff.c,v 1.311 2020/11/28 19:16:53 rillig Exp $");
+MAKE_RCSID("$NetBSD: suff.c,v 1.312 2020/11/28 19:20:03 rillig Exp $");
 
 #define SUFF_DEBUG0(text) DEBUG0(SUFF, text)
 #define SUFF_DEBUG1(fmt, arg1) DEBUG1(SUFF, fmt, arg1)
@@ -607,8 +607,8 @@ Suff_EndTransform(GNode *gn)
     Suffix *srcSuff, *targSuff;
     SuffixList *srcSuffParents;
 
-    if ((gn->type & OP_DOUBLEDEP) && !Lst_IsEmpty(gn->cohorts))
-	gn = gn->cohorts->last->datum;
+    if ((gn->type & OP_DOUBLEDEP) && !Lst_IsEmpty(&gn->cohorts))
+	gn = gn->cohorts.last->datum;
 
     if (!(gn->type & OP_TRANSFORM))
 	return;

Index: src/usr.bin/make/targ.c
diff -u src/usr.bin/make/targ.c:1.144 src/usr.bin/make/targ.c:1.145
--- src/usr.bin/make/targ.c:1.144	Sat Nov 28 19:16:53 2020
+++ src/usr.bin/make/targ.c	Sat Nov 28 19:20:04 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: targ.c,v 1.144 2020/11/28 19:16:53 rillig Exp $	*/
+/*	$NetBSD: targ.c,v 1.145 2020/11/28 19:20:04 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -119,7 +119,7 @@
 #include "dir.h"
 
 /*	"@(#)targ.c	8.2 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: targ.c,v 1.144 2020/11/28 19:16:53 rillig Exp $");
+MAKE_RCSID("$NetBSD: targ.c,v 1.145 2020/11/28 19:20:04 rillig Exp $");
 
 /*
  * All target nodes that appeared on the left-hand side of one of the
@@ -206,7 +206,7 @@ GNode_New(const char *name)
     Lst_Init(&gn->children);
     Lst_Init(&gn->order_pred);
     Lst_Init(&gn->order_succ);
-    gn->cohorts = Lst_New();
+    Lst_Init(&gn->cohorts);
     gn->cohort_num[0] = '\0';
     gn->unmade_cohorts = 0;
     gn->centurion = NULL;
@@ -239,7 +239,7 @@ GNode_Free(void *gnp)
     Lst_Done(&gn->children);	/* likewise */
     Lst_Done(&gn->order_pred);	/* likewise */
     Lst_Done(&gn->order_succ);	/* likewise */
-    Lst_Free(gn->cohorts);	/* likewise */
+    Lst_Done(&gn->cohorts);	/* likewise */
     HashTable_Done(&gn->vars);	/* Do not free the variables themselves,
 				 * even though they are owned by this node.
 				 * XXX: they should probably be freed. */
@@ -519,7 +519,7 @@ Targ_PrintNode(GNode *gn, int pass)
 	Targ_PrintCmds(gn);
 	debug_printf("\n\n");
 	if (gn->type & OP_DOUBLEDEP) {
-	    Targ_PrintNodes(gn->cohorts, pass);
+	    Targ_PrintNodes(&gn->cohorts, pass);
 	}
     }
 }
@@ -596,7 +596,7 @@ Targ_Propagate(void)
 	if (!(type & OP_DOUBLEDEP))
 	    continue;
 
-	for (cln = gn->cohorts->first; cln != NULL; cln = cln->next) {
+	for (cln = gn->cohorts.first; cln != NULL; cln = cln->next) {
 	    GNode *cohort = cln->datum;
 
 	    cohort->type |= type & ~OP_OPMASK;

Reply via email to