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): in CLEANUP mode, preallocate list of a...



details:   https://anonhg.NetBSD.org/src/rev/e76cc833e160
branches:  trunk
changeset: 978315:e76cc833e160
user:      rillig <rillig%NetBSD.org@localhost>
date:      Mon Nov 16 21:44:29 2020 +0000

description:
make(1): in CLEANUP mode, preallocate list of all GNodes

This makes the code simpler and more uniform.

diffstat:

 usr.bin/make/targ.c |  15 ++++++++-------
 1 files changed, 8 insertions(+), 7 deletions(-)

diffs (56 lines):

diff -r 7c3cb0f66721 -r e76cc833e160 usr.bin/make/targ.c
--- a/usr.bin/make/targ.c       Mon Nov 16 21:41:02 2020 +0000
+++ b/usr.bin/make/targ.c       Mon Nov 16 21:44:29 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: targ.c,v 1.129 2020/11/16 21:41:02 rillig Exp $        */
+/*     $NetBSD: targ.c,v 1.130 2020/11/16 21:44:29 rillig Exp $        */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -121,13 +121,14 @@
 #include "dir.h"
 
 /*     "@(#)targ.c     8.2 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: targ.c,v 1.129 2020/11/16 21:41:02 rillig Exp $");
+MAKE_RCSID("$NetBSD: targ.c,v 1.130 2020/11/16 21:44:29 rillig Exp $");
 
 static GNodeList *allTargets;  /* the list of all targets found so far */
+static HashTable targets;      /* a hash table of same */
+
 #ifdef CLEANUP
 static GNodeList *allGNs;      /* List of all the GNodes */
 #endif
-static HashTable targets;      /* a hash table of same */
 
 #ifdef CLEANUP
 static void GNode_Free(void *);
@@ -138,6 +139,9 @@
 {
     allTargets = Lst_New();
     HashTable_Init(&targets);
+#ifdef CLEANUP
+    allGNs = Lst_New();
+#endif
 }
 
 void
@@ -146,9 +150,8 @@
     Targ_Stats();
 #ifdef CLEANUP
     Lst_Free(allTargets);
-    if (allGNs != NULL)
-       Lst_Destroy(allGNs, GNode_Free);
     HashTable_Done(&targets);
+    Lst_Destroy(allGNs, GNode_Free);
 #endif
 }
 
@@ -203,8 +206,6 @@
     gn->lineno = 0;
 
 #ifdef CLEANUP
-    if (allGNs == NULL)
-       allGNs = Lst_New();
     Lst_Append(allGNs, gn);
 #endif
 



Home | Main Index | Thread Index | Old Index