Module Name: src
Committed By: rillig
Date: Sat Sep 5 13:55:08 UTC 2020
Modified Files:
src/usr.bin/make: arch.c dir.c hash.c hash.h targ.c
Log Message:
make(1): remove initial size argument from Hash_InitTable
In all but one case this argument was set to auto-detect anyway. The
one case where it was set was not worth keeping this complicated API.
To generate a diff of this commit:
cvs rdiff -u -r1.107 -r1.108 src/usr.bin/make/arch.c
cvs rdiff -u -r1.135 -r1.136 src/usr.bin/make/dir.c
cvs rdiff -u -r1.30 -r1.31 src/usr.bin/make/hash.c
cvs rdiff -u -r1.21 -r1.22 src/usr.bin/make/hash.h
cvs rdiff -u -r1.82 -r1.83 src/usr.bin/make/targ.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.bin/make/arch.c
diff -u src/usr.bin/make/arch.c:1.107 src/usr.bin/make/arch.c:1.108
--- src/usr.bin/make/arch.c:1.107 Sun Aug 30 11:15:05 2020
+++ src/usr.bin/make/arch.c Sat Sep 5 13:55:08 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: arch.c,v 1.107 2020/08/30 11:15:05 rillig Exp $ */
+/* $NetBSD: arch.c,v 1.108 2020/09/05 13:55:08 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: arch.c,v 1.107 2020/08/30 11:15:05 rillig Exp $";
+static char rcsid[] = "$NetBSD: arch.c,v 1.108 2020/09/05 13:55:08 rillig Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)arch.c 8.2 (Berkeley) 1/2/94";
#else
-__RCSID("$NetBSD: arch.c,v 1.107 2020/08/30 11:15:05 rillig Exp $");
+__RCSID("$NetBSD: arch.c,v 1.108 2020/09/05 13:55:08 rillig Exp $");
#endif
#endif /* not lint */
#endif
@@ -572,7 +572,7 @@ ArchStatMember(const char *archive, cons
ar->name = bmake_strdup(archive);
ar->fnametab = NULL;
ar->fnamesize = 0;
- Hash_InitTable(&ar->members, -1);
+ Hash_InitTable(&ar->members);
memName[AR_MAX_NAME_LEN] = '\0';
while (fread((char *)&arh, sizeof(struct ar_hdr), 1, arch) == 1) {
Index: src/usr.bin/make/dir.c
diff -u src/usr.bin/make/dir.c:1.135 src/usr.bin/make/dir.c:1.136
--- src/usr.bin/make/dir.c:1.135 Wed Sep 2 04:32:13 2020
+++ src/usr.bin/make/dir.c Sat Sep 5 13:55:08 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: dir.c,v 1.135 2020/09/02 04:32:13 rillig Exp $ */
+/* $NetBSD: dir.c,v 1.136 2020/09/05 13:55:08 rillig 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.135 2020/09/02 04:32:13 rillig Exp $";
+static char rcsid[] = "$NetBSD: dir.c,v 1.136 2020/09/05 13:55:08 rillig 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.135 2020/09/02 04:32:13 rillig Exp $");
+__RCSID("$NetBSD: dir.c,v 1.136 2020/09/05 13:55:08 rillig Exp $");
#endif
#endif /* not lint */
#endif
@@ -358,8 +358,8 @@ Dir_Init(void)
{
dirSearchPath = Lst_Init();
openDirectories = Lst_Init();
- Hash_InitTable(&mtimes, 0);
- Hash_InitTable(&lmtimes, 0);
+ Hash_InitTable(&mtimes);
+ Hash_InitTable(&lmtimes);
}
void
@@ -371,7 +371,7 @@ Dir_InitDir(const char *cdname)
dotLast->refCount = 1;
dotLast->hits = 0;
dotLast->name = bmake_strdup(".DOTLAST");
- Hash_InitTable(&dotLast->files, -1);
+ Hash_InitTable(&dotLast->files);
}
/*
@@ -1547,7 +1547,7 @@ Dir_AddDir(Lst path, const char *name)
p->name = bmake_strdup(name);
p->hits = 0;
p->refCount = 1;
- Hash_InitTable(&p->files, -1);
+ Hash_InitTable(&p->files);
while ((dp = readdir(d)) != NULL) {
#if defined(sun) && defined(d_ino) /* d_ino is a sunos4 #define for d_fileno */
Index: src/usr.bin/make/hash.c
diff -u src/usr.bin/make/hash.c:1.30 src/usr.bin/make/hash.c:1.31
--- src/usr.bin/make/hash.c:1.30 Sat Sep 5 13:36:25 2020
+++ src/usr.bin/make/hash.c Sat Sep 5 13:55:08 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: hash.c,v 1.30 2020/09/05 13:36:25 rillig Exp $ */
+/* $NetBSD: hash.c,v 1.31 2020/09/05 13:55:08 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -70,14 +70,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: hash.c,v 1.30 2020/09/05 13:36:25 rillig Exp $";
+static char rcsid[] = "$NetBSD: hash.c,v 1.31 2020/09/05 13:55:08 rillig Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)hash.c 8.1 (Berkeley) 6/6/93";
#else
-__RCSID("$NetBSD: hash.c,v 1.30 2020/09/05 13:36:25 rillig Exp $");
+__RCSID("$NetBSD: hash.c,v 1.31 2020/09/05 13:55:08 rillig Exp $");
#endif
#endif /* not lint */
#endif
@@ -120,33 +120,20 @@ static void RebuildTable(Hash_Table *);
*
* Input:
* t Structure to to hold the table.
- * numBuckets How many buckets to create for starters. This
- * number is rounded up to a power of two. If
- * <= 0, a reasonable default is chosen. The
- * table will grow in size later as needed.
*/
void
-Hash_InitTable(Hash_Table *t, int numBuckets)
+Hash_InitTable(Hash_Table *t)
{
- int i;
+ size_t n = 16, i;
struct Hash_Entry **hp;
- /*
- * Round up the size to a power of two.
- */
- if (numBuckets <= 0)
- i = 16;
- else {
- for (i = 2; i < numBuckets; i <<= 1)
- continue;
- }
t->numEntries = 0;
t->maxchain = 0;
- t->bucketsSize = i;
- t->bucketsMask = i - 1;
- t->buckets = hp = bmake_malloc(sizeof(*hp) * i);
- while (--i >= 0)
- *hp++ = NULL;
+ t->bucketsSize = n;
+ t->bucketsMask = n - 1;
+ t->buckets = hp = bmake_malloc(sizeof(*hp) * n);
+ for (i = 0; i < n; i++)
+ hp[i] = NULL;
}
/* Removes everything from the hash table and frees up the memory space it
Index: src/usr.bin/make/hash.h
diff -u src/usr.bin/make/hash.h:1.21 src/usr.bin/make/hash.h:1.22
--- src/usr.bin/make/hash.h:1.21 Tue Sep 1 21:11:31 2020
+++ src/usr.bin/make/hash.h Sat Sep 5 13:55:08 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: hash.h,v 1.21 2020/09/01 21:11:31 rillig Exp $ */
+/* $NetBSD: hash.h,v 1.22 2020/09/05 13:55:08 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -118,7 +118,7 @@ Hash_SetValue(Hash_Entry *h, void *datum
h->value = datum;
}
-void Hash_InitTable(Hash_Table *, int);
+void Hash_InitTable(Hash_Table *);
void Hash_DeleteTable(Hash_Table *);
Hash_Entry *Hash_FindEntry(Hash_Table *, const char *);
Hash_Entry *Hash_CreateEntry(Hash_Table *, const char *, Boolean *);
Index: src/usr.bin/make/targ.c
diff -u src/usr.bin/make/targ.c:1.82 src/usr.bin/make/targ.c:1.83
--- src/usr.bin/make/targ.c:1.82 Sat Sep 5 06:46:12 2020
+++ src/usr.bin/make/targ.c Sat Sep 5 13:55:08 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: targ.c,v 1.82 2020/09/05 06:46:12 rillig Exp $ */
+/* $NetBSD: targ.c,v 1.83 2020/09/05 13:55:08 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: targ.c,v 1.82 2020/09/05 06:46:12 rillig Exp $";
+static char rcsid[] = "$NetBSD: targ.c,v 1.83 2020/09/05 13:55:08 rillig Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)targ.c 8.2 (Berkeley) 3/19/94";
#else
-__RCSID("$NetBSD: targ.c,v 1.82 2020/09/05 06:46:12 rillig Exp $");
+__RCSID("$NetBSD: targ.c,v 1.83 2020/09/05 13:55:08 rillig Exp $");
#endif
#endif /* not lint */
#endif
@@ -150,7 +150,7 @@ void
Targ_Init(void)
{
allTargets = Lst_Init();
- Hash_InitTable(&targets, 191);
+ Hash_InitTable(&targets);
}
void
@@ -209,7 +209,7 @@ Targ_NewGN(const char *name)
gn->children = Lst_Init();
gn->order_pred = Lst_Init();
gn->order_succ = Lst_Init();
- Hash_InitTable(&gn->context, 0);
+ Hash_InitTable(&gn->context);
gn->commands = Lst_Init();
gn->suffix = NULL;
gn->fname = NULL;