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): replace a few calls to Lst_Open with s...



details:   https://anonhg.NetBSD.org/src/rev/f749e81d9536
branches:  trunk
changeset: 939089:f749e81d9536
user:      rillig <rillig%NetBSD.org@localhost>
date:      Fri Sep 25 06:49:13 2020 +0000

description:
make(1): replace a few calls to Lst_Open with simple loops

This avoids relying on the internal iterator of the list, which is
supposed to be removed in the near future.

diffstat:

 usr.bin/make/arch.c |  12 ++++--------
 usr.bin/make/dir.c  |  29 +++++++++++------------------
 2 files changed, 15 insertions(+), 26 deletions(-)

diffs (119 lines):

diff -r 7c3980b1036c -r f749e81d9536 usr.bin/make/arch.c
--- a/usr.bin/make/arch.c       Fri Sep 25 06:47:24 2020 +0000
+++ b/usr.bin/make/arch.c       Fri Sep 25 06:49:13 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: arch.c,v 1.118 2020/09/22 20:19:46 rillig Exp $        */
+/*     $NetBSD: arch.c,v 1.119 2020/09/25 06:49:13 rillig Exp $        */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -133,7 +133,7 @@
 #include    "config.h"
 
 /*     "@(#)arch.c     8.2 (Berkeley) 1/2/94"  */
-MAKE_RCSID("$NetBSD: arch.c,v 1.118 2020/09/22 20:19:46 rillig Exp $");
+MAKE_RCSID("$NetBSD: arch.c,v 1.119 2020/09/25 06:49:13 rillig Exp $");
 
 #ifdef TARGET_MACHINE
 #undef MAKE_MACHINE
@@ -1026,11 +1026,9 @@
 Arch_MemMTime(GNode *gn)
 {
     GNodeListNode *ln;
-    GNode        *pgn;
 
-    Lst_Open(gn->parents);
-    while ((ln = Lst_Next(gn->parents)) != NULL) {
-       pgn = LstNode_Datum(ln);
+    for (ln = gn->parents->first; ln != NULL; ln = ln->next) {
+       GNode *pgn = ln->datum;
 
        if (pgn->type & OP_ARCHV) {
            /*
@@ -1058,8 +1056,6 @@
        }
     }
 
-    Lst_Close(gn->parents);
-
     return gn->mtime;
 }
 
diff -r 7c3980b1036c -r f749e81d9536 usr.bin/make/dir.c
--- a/usr.bin/make/dir.c        Fri Sep 25 06:47:24 2020 +0000
+++ b/usr.bin/make/dir.c        Fri Sep 25 06:49:13 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: dir.c,v 1.146 2020/09/24 07:49:58 rillig Exp $ */
+/*     $NetBSD: dir.c,v 1.147 2020/09/25 06:49:13 rillig Exp $ */
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -134,7 +134,7 @@
 #include "job.h"
 
 /*     "@(#)dir.c      8.2 (Berkeley) 1/2/94"  */
-MAKE_RCSID("$NetBSD: dir.c,v 1.146 2020/09/24 07:49:58 rillig Exp $");
+MAKE_RCSID("$NetBSD: dir.c,v 1.147 2020/09/25 06:49:13 rillig Exp $");
 
 #define DIR_DEBUG0(fmt) \
     if (!DEBUG(DIR)) (void) 0; else fprintf(debug_file, fmt)
@@ -747,21 +747,18 @@
 DirExpandInt(const char *word, SearchPath *path, StringList *expansions)
 {
     SearchPathNode *ln;
-
-    Lst_Open(path);
-    while ((ln = Lst_Next(path)) != NULL) {
-       CachedDir *dir = LstNode_Datum(ln);
+    for (ln = path->first; ln != NULL; ln = ln->next) {
+       CachedDir *dir = ln->datum;
        DirMatchFiles(word, dir, expansions);
     }
-    Lst_Close(path);
 }
 
 static void
 DirPrintExpansions(StringList *words)
 {
-    StringListNode *node;
-    for (node = Lst_First(words); node != NULL; node = LstNode_Next(node)) {
-       const char *word = LstNode_Datum(node);
+    StringListNode *ln;
+    for (ln = words->first; ln != NULL; ln = ln->next) {
+       const char *word = ln->datum;
        fprintf(debug_file, "%s ", word);
     }
     fprintf(debug_file, "\n");
@@ -1611,14 +1608,12 @@
     Buf_Init(&buf, 0);
 
     if (path != NULL) {
-       Lst_Open(path);
-       while ((ln = Lst_Next(path)) != NULL) {
-           CachedDir *dir = LstNode_Datum(ln);
+       for (ln = path->first; ln != NULL; ln = ln->next) {
+           CachedDir *dir = ln->datum;
            Buf_AddStr(&buf, " ");
            Buf_AddStr(&buf, flag);
            Buf_AddStr(&buf, dir->name);
        }
-       Lst_Close(path);
     }
 
     return Buf_Destroy(&buf, FALSE);
@@ -1740,13 +1735,11 @@
            percentage(hits, hits + bigmisses + nearmisses));
     fprintf(debug_file, "# %-20s referenced\thits\n", "directory");
 
-    Lst_Open(openDirectories);
-    while ((ln = Lst_Next(openDirectories)) != NULL) {
-       CachedDir *dir = LstNode_Datum(ln);
+    for (ln = openDirectories->first; ln != NULL; ln = ln->next) {
+       CachedDir *dir = ln->datum;
        fprintf(debug_file, "# %-20s %10d\t%4d\n", dir->name, dir->refCount,
                dir->hits);
     }
-    Lst_Close(openDirectories);
 }
 
 void



Home | Main Index | Thread Index | Old Index