Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/make Remove duplicate code in make(1)'s dir.c.



details:   https://anonhg.NetBSD.org/src/rev/e035f74710b5
branches:  trunk
changeset: 324020:e035f74710b5
user:      reinoud <reinoud%NetBSD.org@localhost>
date:      Thu Jul 12 17:46:37 2018 +0000

description:
Remove duplicate code in make(1)'s dir.c.

When the cached_stats() code was added, some old logic stayed around that
implements the cached_stats() too.

diffstat:

 usr.bin/make/dir.c |  39 ++++++++-------------------------------
 1 files changed, 8 insertions(+), 31 deletions(-)

diffs (95 lines):

diff -r dbc9c6cb620b -r e035f74710b5 usr.bin/make/dir.c
--- a/usr.bin/make/dir.c        Thu Jul 12 13:05:39 2018 +0000
+++ b/usr.bin/make/dir.c        Thu Jul 12 17:46:37 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: dir.c,v 1.71 2017/04/16 21:14:47 riastradh Exp $       */
+/*     $NetBSD: dir.c,v 1.72 2018/07/12 17:46:37 reinoud Exp $ */
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -70,14 +70,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: dir.c,v 1.71 2017/04/16 21:14:47 riastradh Exp $";
+static char rcsid[] = "$NetBSD: dir.c,v 1.72 2018/07/12 17:46:37 reinoud Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)dir.c      8.2 (Berkeley) 1/2/94";
 #else
-__RCSID("$NetBSD: dir.c,v 1.71 2017/04/16 21:14:47 riastradh Exp $");
+__RCSID("$NetBSD: dir.c,v 1.72 2018/07/12 17:46:37 reinoud Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -268,15 +268,6 @@
 };
 
 /* minimize changes below */
-static time_t
-Hash_GetTimeValue(Hash_Entry *entry)
-{
-    struct cache_st *cst;
-
-    cst = entry->clientPtr;
-    return cst->mtime;
-}
-
 #define CST_LSTAT 1
 #define CST_UPDATE 2
 
@@ -1134,7 +1125,6 @@
     Boolean      hasLastDot = FALSE;   /* true we should search dot last */
     Boolean      hasSlash;             /* true if 'name' contains a / */
     struct stat          stb;                  /* Buffer for stat, if necessary */
-    Hash_Entry   *entry;               /* Entry for mtimes table */
     const char   *trailing_dot = ".";
 
     /*
@@ -1395,13 +1385,7 @@
     }
 
     bigmisses += 1;
-    entry = Hash_FindEntry(&mtimes, name);
-    if (entry != NULL) {
-       if (DEBUG(DIR)) {
-           fprintf(debug_file, "   got it (in mtime cache)\n");
-       }
-       return(bmake_strdup(name));
-    } else if (cached_stat(name, &stb) == 0) {
+    if (cached_stat(name, &stb) == 0) {
        if (DEBUG(DIR)) {
            fprintf(debug_file, "   Caching %s for %s\n", Targ_FmtTime(stb.st_mtime),
                    name);
@@ -1518,7 +1502,6 @@
 {
     char          *fullName;  /* the full pathname of name */
     struct stat          stb;        /* buffer for finding the mod time */
-    Hash_Entry   *entry;
 
     if (gn->type & OP_ARCHV) {
        return Arch_MTime(gn);
@@ -1569,17 +1552,11 @@
        fullName = bmake_strdup(gn->name);
     }
 
-    if (!recheck)
-       entry = Hash_FindEntry(&mtimes, fullName);
-    else
-       entry = NULL;
-    if (entry != NULL) {
-       stb.st_mtime = Hash_GetTimeValue(entry);
-       if (DEBUG(DIR)) {
-           fprintf(debug_file, "Using cached time %s for %s\n",
-                   Targ_FmtTime(stb.st_mtime), fullName);
+    if (cached_stats(&mtimes, fullName, &stb, recheck ? CST_UPDATE : 0) < 0) {
+        if (DEBUG(DIR)) {
+            fprintf(debug_file, "Using cached time %s for %s\n",
+               Targ_FmtTime(stb.st_mtime), fullName);
        }
-    } else if (cached_stats(&mtimes, fullName, &stb, recheck ? CST_UPDATE : 0) < 0) {
        if (gn->type & OP_MEMBER) {
            if (fullName != gn->path)
                free(fullName);



Home | Main Index | Thread Index | Old Index