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): reduce memory allocation for GNode.par...



details:   https://anonhg.NetBSD.org/src/rev/e6cc7400a9f1
branches:  trunk
changeset: 957438:e6cc7400a9f1
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Nov 28 19:12:28 2020 +0000

description:
make(1): reduce memory allocation for GNode.parents and GNode.children

diffstat:

 usr.bin/make/arch.c   |  10 +++++-----
 usr.bin/make/compat.c |   6 +++---
 usr.bin/make/job.c    |   8 ++++----
 usr.bin/make/make.c   |  46 +++++++++++++++++++++++-----------------------
 usr.bin/make/make.h   |   6 +++---
 usr.bin/make/parse.c  |   8 ++++----
 usr.bin/make/suff.c   |  48 ++++++++++++++++++++++++------------------------
 usr.bin/make/targ.c   |  16 ++++++++--------
 8 files changed, 74 insertions(+), 74 deletions(-)

diffs (truncated from 553 to 300 lines):

diff -r a5f24b2f4481 -r e6cc7400a9f1 usr.bin/make/arch.c
--- a/usr.bin/make/arch.c       Sat Nov 28 18:55:52 2020 +0000
+++ b/usr.bin/make/arch.c       Sat Nov 28 19:12:28 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: arch.c,v 1.178 2020/11/23 19:02:54 rillig Exp $        */
+/*     $NetBSD: arch.c,v 1.179 2020/11/28 19:12:28 rillig Exp $        */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -125,7 +125,7 @@
 #include "config.h"
 
 /*     "@(#)arch.c     8.2 (Berkeley) 1/2/94"  */
-MAKE_RCSID("$NetBSD: arch.c,v 1.178 2020/11/23 19:02:54 rillig Exp $");
+MAKE_RCSID("$NetBSD: arch.c,v 1.179 2020/11/28 19:12:28 rillig Exp $");
 
 typedef struct List ArchList;
 typedef struct ListNode ArchListNode;
@@ -925,7 +925,7 @@
 {
        GNodeListNode *ln;
 
-       for (ln = gn->parents->first; ln != NULL; ln = ln->next) {
+       for (ln = gn->parents.first; ln != NULL; ln = ln->next) {
                GNode *pgn = ln->datum;
 
                if (pgn->type & OP_ARCHV) {
@@ -1021,9 +1021,9 @@
 
        if (gn->type & OP_PHONY) {
                oodate = TRUE;
-       } else if (!GNode_IsTarget(gn) && Lst_IsEmpty(gn->children)) {
+       } else if (!GNode_IsTarget(gn) && Lst_IsEmpty(&gn->children)) {
                oodate = FALSE;
-       } else if ((!Lst_IsEmpty(gn->children) && gn->youngestChild == NULL) ||
+       } else if ((!Lst_IsEmpty(&gn->children) && gn->youngestChild == NULL) ||
                   (gn->mtime > now) ||
                   (gn->youngestChild != NULL &&
                    gn->mtime < gn->youngestChild->mtime)) {
diff -r a5f24b2f4481 -r e6cc7400a9f1 usr.bin/make/compat.c
--- a/usr.bin/make/compat.c     Sat Nov 28 18:55:52 2020 +0000
+++ b/usr.bin/make/compat.c     Sat Nov 28 19:12:28 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: compat.c,v 1.193 2020/11/28 18:55:52 rillig Exp $      */
+/*     $NetBSD: compat.c,v 1.194 2020/11/28 19:12:28 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.193 2020/11/28 18:55:52 rillig Exp $");
+MAKE_RCSID("$NetBSD: compat.c,v 1.194 2020/11/28 19:12:28 rillig Exp $");
 
 static GNode *curTarg = NULL;
 static pid_t compatChild;
@@ -487,7 +487,7 @@
        if (!(gn->type & OP_MADE))
                Suff_FindDeps(gn);
 
-       MakeNodes(gn->children, gn);
+       MakeNodes(&gn->children, gn);
 
        if (!(gn->flags & REMAKE)) {
                gn->made = ABORTED;
diff -r a5f24b2f4481 -r e6cc7400a9f1 usr.bin/make/job.c
--- a/usr.bin/make/job.c        Sat Nov 28 18:55:52 2020 +0000
+++ b/usr.bin/make/job.c        Sat Nov 28 19:12:28 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: job.c,v 1.332 2020/11/28 18:55:52 rillig Exp $ */
+/*     $NetBSD: job.c,v 1.333 2020/11/28 19:12:28 rillig Exp $ */
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -143,7 +143,7 @@
 #include "trace.h"
 
 /*     "@(#)job.c      8.2 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: job.c,v 1.332 2020/11/28 18:55:52 rillig Exp $");
+MAKE_RCSID("$NetBSD: job.c,v 1.333 2020/11/28 19:12:28 rillig Exp $");
 
 /* A shell defines how the commands are run.  All commands for a target are
  * written into a single file, which is then given to the shell to execute
@@ -1177,7 +1177,7 @@
        return TRUE;
     if (!Lst_IsEmpty(&gn->commands))
        return TRUE;
-    if ((gn->type & OP_LIB) && !Lst_IsEmpty(gn->children))
+    if ((gn->type & OP_LIB) && !Lst_IsEmpty(&gn->children))
        return TRUE;
 
     /*
@@ -2451,7 +2451,7 @@
 Job_Finish(void)
 {
     GNode *endNode = Targ_GetEndNode();
-    if (!Lst_IsEmpty(&endNode->commands) || !Lst_IsEmpty(endNode->children)) {
+    if (!Lst_IsEmpty(&endNode->commands) || !Lst_IsEmpty(&endNode->children)) {
        if (job_errors != 0) {
            Error("Errors reported so .END ignored");
        } else {
diff -r a5f24b2f4481 -r e6cc7400a9f1 usr.bin/make/make.c
--- a/usr.bin/make/make.c       Sat Nov 28 18:55:52 2020 +0000
+++ b/usr.bin/make/make.c       Sat Nov 28 19:12:28 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: make.c,v 1.219 2020/11/28 18:55:52 rillig Exp $        */
+/*     $NetBSD: make.c,v 1.220 2020/11/28 19:12:28 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.219 2020/11/28 18:55:52 rillig Exp $");
+MAKE_RCSID("$NetBSD: make.c,v 1.220 2020/11/28 19:12:28 rillig Exp $");
 
 /* Sequence # to detect recursion. */
 static unsigned int checked_seqno = 1;
@@ -329,7 +329,7 @@
      */
     if (!oodate) {
        GNodeListNode *ln;
-       for (ln = gn->parents->first; ln != NULL; ln = ln->next)
+       for (ln = gn->parents.first; ln != NULL; ln = ln->next)
            GNode_UpdateYoungestChild(ln->datum, gn);
     }
 
@@ -341,7 +341,7 @@
 {
        GNodeListNode *ln;
 
-       for (ln = pgn->children->first; ln != NULL; ln = ln->next) {
+       for (ln = pgn->children.first; ln != NULL; ln = ln->next) {
                GNode *cgn = ln->datum;
 
                /* This may also update cgn->path. */
@@ -386,7 +386,7 @@
        }
     }
 
-    for (ln = cgn->children->first; ln != NULL; ln = ln->next) {
+    for (ln = cgn->children.first; ln != NULL; ln = ln->next) {
        GNode *gn = ln->datum;
 
        /*
@@ -409,8 +409,8 @@
                gn = tgn;
        }
 
-       Lst_Append(pgn->children, gn);
-       Lst_Append(gn->parents, pgn);
+       Lst_Append(&pgn->children, gn);
+       Lst_Append(&gn->parents, pgn);
        pgn->unmade++;
     }
 
@@ -449,7 +449,7 @@
      * children the parent has. This is used by Make_Run to decide
      * whether to queue the parent or examine its children...
      */
-    Lst_Remove(pgn->children, ln);
+    Lst_Remove(&pgn->children, ln);
     pgn->unmade--;
 }
 
@@ -457,7 +457,7 @@
 HandleUseNodes(GNode *gn)
 {
        GNodeListNode *ln, *nln;
-       for (ln = gn->children->first; ln != NULL; ln = nln) {
+       for (ln = gn->children.first; ln != NULL; ln = nln) {
                nln = ln->next;
                MakeHandleUse(ln->datum, gn, ln);
        }
@@ -642,7 +642,7 @@
      * which is where all parents are linked.
      */
     if ((centurion = cgn->centurion) != NULL) {
-       if (!Lst_IsEmpty(cgn->parents))
+       if (!Lst_IsEmpty(&cgn->parents))
                Punt("%s%s: cohort has parents", cgn->name, cgn->cohort_num);
        centurion->unmade_cohorts--;
        if (centurion->unmade_cohorts < 0)
@@ -650,7 +650,7 @@
     } else {
        centurion = cgn;
     }
-    parents = centurion->parents;
+    parents = &centurion->parents;
 
     /* If this was a .ORDER node, schedule the RHS */
     ScheduleOrderSuccessors(centurion);
@@ -751,7 +751,7 @@
 {
        GNodeListNode *ln;
 
-       for (ln = gn->children->first; ln != NULL; ln = ln->next) {
+       for (ln = gn->children.first; ln != NULL; ln = ln->next) {
                GNode *child = ln->datum;
                child->type &= ~OP_MARK;
        }
@@ -846,7 +846,7 @@
                return;
 
        UnmarkChildren(gn);
-       for (ln = gn->children->first; ln != NULL; ln = ln->next)
+       for (ln = gn->children.first; ln != NULL; ln = ln->next)
                MakeAddAllSrc(ln->datum, gn);
 
        if (!Var_Exists(OODATE, gn))
@@ -964,7 +964,7 @@
                GNodeListNode *toBeMadeNext = toBeMade->first;
                GNodeListNode *ln;
 
-               for (ln = gn->children->first; ln != NULL; ln = ln->next)
+               for (ln = gn->children.first; ln != NULL; ln = ln->next)
                    if (MakeBuildChild(ln->datum, toBeMadeNext) != 0)
                        break;
            }
@@ -1086,7 +1086,7 @@
     if (!(gn->flags & CYCLE)) {
        /* First time we've seen this node, check all children */
        gn->flags |= CYCLE;
-       MakePrintStatusList(gn->children, errors);
+       MakePrintStatusList(&gn->children, errors);
        /* Mark that this node needn't be processed again */
        gn->flags |= DONECYCLE;
        return FALSE;
@@ -1100,7 +1100,7 @@
        return TRUE;
 
     /* Reporting for our children will give the rest of the loop */
-    MakePrintStatusList(gn->children, errors);
+    MakePrintStatusList(&gn->children, errors);
     return FALSE;
 }
 
@@ -1199,7 +1199,7 @@
        }
 
        if (gn->unmade != 0)
-           ExamineLater(examine, gn->children);
+           ExamineLater(examine, &gn->children);
     }
 
     Lst_Free(examine);
@@ -1217,9 +1217,9 @@
                    cn->name, cn->cohort_num, wn->name);
 
                /* XXX: This pattern should be factored out, it repeats often */
-               Lst_Append(wn->children, cn);
+               Lst_Append(&wn->children, cn);
                wn->unmade++;
-               Lst_Append(cn->parents, wn);
+               Lst_Append(&cn->parents, wn);
        }
 }
 
@@ -1248,8 +1248,8 @@
        for (ln = targs->first; ln != NULL; ln = ln->next) {
            GNode *cgn = ln->datum;
 
-           Lst_Append(pgn->children, cgn);
-           Lst_Append(cgn->parents, pgn);
+           Lst_Append(&pgn->children, cgn);
+           Lst_Append(&cgn->parents, pgn);
            pgn->unmade++;
        }
     }
@@ -1274,8 +1274,8 @@
        if (pgn->type & OP_DOUBLEDEP)
            Lst_PrependAll(examine, pgn->cohorts);
 
-       owln = pgn->children->first;
-       for (ln = pgn->children->first; ln != NULL; ln = ln->next) {
+       owln = pgn->children.first;
+       for (ln = pgn->children.first; ln != NULL; ln = ln->next) {
            GNode *cgn = ln->datum;
            if (cgn->type & OP_WAIT) {
                add_wait_dependency(owln, cgn);
diff -r a5f24b2f4481 -r e6cc7400a9f1 usr.bin/make/make.h
--- a/usr.bin/make/make.h       Sat Nov 28 18:55:52 2020 +0000
+++ b/usr.bin/make/make.h       Sat Nov 28 19:12:28 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: make.h,v 1.221 2020/11/28 18:55:52 rillig Exp $        */
+/*     $NetBSD: make.h,v 1.222 2020/11/28 19:12:28 rillig Exp $        */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -387,9 +387,9 @@
 
        /* The nodes that depend on this one, or in other words, the nodes for
         * which this is a source. */
-       GNodeList *parents;
+       GNodeList parents;
        /* The nodes on which this one depends. */
-       GNodeList *children;
+       GNodeList children;



Home | Main Index | Thread Index | Old Index