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_Find in meta_oodate



details:   https://anonhg.NetBSD.org/src/rev/586436222732
branches:  trunk
changeset: 956229:586436222732
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Oct 24 10:32:25 2020 +0000

description:
make(1): inline Lst_Find in meta_oodate

diffstat:

 usr.bin/make/meta.c |  29 +++++++++++++++--------------
 1 files changed, 15 insertions(+), 14 deletions(-)

diffs (64 lines):

diff -r 4893f2a33cd6 -r 586436222732 usr.bin/make/meta.c
--- a/usr.bin/make/meta.c       Sat Oct 24 10:18:29 2020 +0000
+++ b/usr.bin/make/meta.c       Sat Oct 24 10:32:25 2020 +0000
@@ -1,4 +1,4 @@
-/*      $NetBSD: meta.c,v 1.129 2020/10/24 10:17:21 rillig Exp $ */
+/*      $NetBSD: meta.c,v 1.130 2020/10/24 10:32:25 rillig Exp $ */
 
 /*
  * Implement 'meta' mode.
@@ -970,13 +970,6 @@
     return path[n] == '\0' || path[n] == '/';
 }
 
-static Boolean
-string_match(const void *p, const void *q)
-{
-    return strcmp(p, q) == 0;
-}
-
-
 static int
 meta_ignore(GNode *gn, const char *p)
 {
@@ -1060,6 +1053,17 @@
        *ep = '\0'; \
     }
 
+static void
+append_if_new(StringList *list, const char *str)
+{
+    StringListNode *ln;
+
+    for (ln = list->first; ln != NULL; ln = ln->next)
+        if (strcmp(ln->datum, str) == 0)
+           return;
+    Lst_Append(list, bmake_strdup(str));
+}
+
 Boolean
 meta_oodate(GNode *gn, Boolean oodate)
 {
@@ -1384,10 +1388,8 @@
 
                    if ((link_src != NULL && cached_lstat(p, &mst) < 0) ||
                        (link_src == NULL && cached_stat(p, &mst) < 0)) {
-                       if (!meta_ignore(gn, p)) {
-                           if (Lst_Find(missingFiles, string_match, p) == NULL)
-                               Lst_Append(missingFiles, bmake_strdup(p));
-                       }
+                       if (!meta_ignore(gn, p))
+                           append_if_new(missingFiles, p);
                    }
                    break;
                check_link_src:
@@ -1470,8 +1472,7 @@
                             * A referenced file outside of CWD is missing.
                             * We cannot catch every eventuality here...
                             */
-                           if (Lst_Find(missingFiles, string_match, p) == NULL)
-                               Lst_Append(missingFiles, bmake_strdup(p));
+                           append_if_new(missingFiles, p);
                        }
                    }
                    if (buf[0] == 'E') {



Home | Main Index | Thread Index | Old Index