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): migrate CachedDir.files from HashTable...
details: https://anonhg.NetBSD.org/src/rev/8622c51cc56e
branches: trunk
changeset: 957293:8622c51cc56e
user: rillig <rillig%NetBSD.org@localhost>
date: Mon Nov 23 18:24:05 2020 +0000
description:
make(1): migrate CachedDir.files from HashTable to HashSet
diffstat:
usr.bin/make/dir.c | 22 +++++++++++-----------
usr.bin/make/dir.h | 5 ++---
usr.bin/make/hash.h | 8 +++++++-
3 files changed, 20 insertions(+), 15 deletions(-)
diffs (137 lines):
diff -r 7be701d18cca -r 8622c51cc56e usr.bin/make/dir.c
--- a/usr.bin/make/dir.c Mon Nov 23 18:07:10 2020 +0000
+++ b/usr.bin/make/dir.c Mon Nov 23 18:24:05 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dir.c,v 1.210 2020/11/14 21:29:44 rillig Exp $ */
+/* $NetBSD: dir.c,v 1.211 2020/11/23 18:24:05 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.210 2020/11/14 21:29:44 rillig Exp $");
+MAKE_RCSID("$NetBSD: dir.c,v 1.211 2020/11/23 18:24:05 rillig Exp $");
#define DIR_DEBUG0(text) DEBUG0(DIR, text)
#define DIR_DEBUG1(fmt, arg1) DEBUG1(DIR, fmt, arg1)
@@ -379,7 +379,7 @@
dotLast->refCount = 1;
dotLast->hits = 0;
dotLast->name = bmake_strdup(".DOTLAST");
- HashTable_Init(&dotLast->files);
+ HashSet_Init(&dotLast->files);
}
/*
@@ -573,7 +573,7 @@
/* XXX: Iterating over all hash entries is inefficient. If the pattern
* is a plain string without any wildcards, a direct lookup is faster. */
- HashIter_Init(&hi, &dir->files);
+ HashIter_InitSet(&hi, &dir->files);
while (HashIter_Next(&hi) != NULL) {
const char *base = hi.entry->key;
@@ -848,7 +848,7 @@
DIR_DEBUG1(" %s ...\n", dir->name);
- if (HashTable_FindEntry(&dir->files, base) == NULL)
+ if (!HashSet_Contains(&dir->files, base))
return NULL;
file = str_concat3(dir->name, "/", base);
@@ -901,7 +901,7 @@
if (*dnp != '\0' || np != cp - 1)
return NULL;
- if (HashTable_FindEntry(&dir->files, cp) == NULL) {
+ if (!HashSet_Contains(&dir->files, cp)) {
DIR_DEBUG0(" must be here but isn't -- returning\n");
return bmake_strdup(""); /* to terminate the search */
}
@@ -918,14 +918,14 @@
DirFindDot(const char *name, const char *base)
{
- if (HashTable_FindEntry(&dot->files, base) != NULL) {
+ if (HashSet_Contains(&dot->files, base)) {
DIR_DEBUG0(" in '.'\n");
hits++;
dot->hits++;
return bmake_strdup(name);
}
- if (cur != NULL && HashTable_FindEntry(&cur->files, base) != NULL) {
+ if (cur != NULL && HashSet_Contains(&cur->files, base)) {
DIR_DEBUG1(" in ${.CURDIR} = %s\n", cur->name);
hits++;
cur->hits++;
@@ -1390,7 +1390,7 @@
dir->name = bmake_strdup(name);
dir->hits = 0;
dir->refCount = 1;
- HashTable_Init(&dir->files);
+ HashSet_Init(&dir->files);
while ((dp = readdir(d)) != NULL) {
#if defined(sun) && defined(d_ino) /* d_ino is a sunos4 #define for d_fileno */
@@ -1403,7 +1403,7 @@
continue;
}
#endif /* sun && d_ino */
- (void)HashTable_CreateEntry(&dir->files, dp->d_name, NULL);
+ (void)HashSet_Add(&dir->files, dp->d_name);
}
(void)closedir(d);
OpenDirs_Add(&openDirs, dir);
@@ -1485,7 +1485,7 @@
if (dir->refCount == 0) {
OpenDirs_Remove(&openDirs, dir->name);
- HashTable_Done(&dir->files);
+ HashSet_Done(&dir->files);
free(dir->name);
free(dir);
}
diff -r 7be701d18cca -r 8622c51cc56e usr.bin/make/dir.h
--- a/usr.bin/make/dir.h Mon Nov 23 18:07:10 2020 +0000
+++ b/usr.bin/make/dir.h Mon Nov 23 18:24:05 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dir.h,v 1.34 2020/11/14 19:24:24 rillig Exp $ */
+/* $NetBSD: dir.h,v 1.35 2020/11/23 18:24:05 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -87,8 +87,7 @@
int refCount; /* Number of SearchPaths with this directory */
int hits; /* The number of times a file in this
* directory has been found */
- HashTable files; /* Hash set of files in directory;
- * all values are NULL. */
+ HashSet files; /* The files in the directory. */
} CachedDir;
void Dir_Init(void);
diff -r 7be701d18cca -r 8622c51cc56e usr.bin/make/hash.h
--- a/usr.bin/make/hash.h Mon Nov 23 18:07:10 2020 +0000
+++ b/usr.bin/make/hash.h Mon Nov 23 18:24:05 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: hash.h,v 1.35 2020/11/23 18:07:10 rillig Exp $ */
+/* $NetBSD: hash.h,v 1.36 2020/11/23 18:24:05 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -161,4 +161,10 @@
return HashTable_FindEntry(&set->tbl, key) != NULL;
}
+MAKE_INLINE void
+HashIter_InitSet(HashIter *hi, HashSet *set)
+{
+ HashIter_Init(hi, &set->tbl);
+}
+
#endif /* MAKE_HASH_H */
Home |
Main Index |
Thread Index |
Old Index