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): remove initial size argument from Hash...
details: https://anonhg.NetBSD.org/src/rev/8df04568f60a
branches: trunk
changeset: 954510:8df04568f60a
user: rillig <rillig%NetBSD.org@localhost>
date: Sat Sep 05 13:55:08 2020 +0000
description:
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.
diffstat:
usr.bin/make/arch.c | 8 ++++----
usr.bin/make/dir.c | 14 +++++++-------
usr.bin/make/hash.c | 33 ++++++++++-----------------------
usr.bin/make/hash.h | 4 ++--
usr.bin/make/targ.c | 10 +++++-----
5 files changed, 28 insertions(+), 41 deletions(-)
diffs (219 lines):
diff -r 075f583f0877 -r 8df04568f60a usr.bin/make/arch.c
--- a/usr.bin/make/arch.c Sat Sep 05 13:41:00 2020 +0000
+++ b/usr.bin/make/arch.c Sat Sep 05 13:55:08 2020 +0000
@@ -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 @@
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) {
diff -r 075f583f0877 -r 8df04568f60a usr.bin/make/dir.c
--- a/usr.bin/make/dir.c Sat Sep 05 13:41:00 2020 +0000
+++ b/usr.bin/make/dir.c Sat Sep 05 13:55:08 2020 +0000
@@ -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 @@
{
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 @@
dotLast->refCount = 1;
dotLast->hits = 0;
dotLast->name = bmake_strdup(".DOTLAST");
- Hash_InitTable(&dotLast->files, -1);
+ Hash_InitTable(&dotLast->files);
}
/*
@@ -1547,7 +1547,7 @@
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 */
diff -r 075f583f0877 -r 8df04568f60a usr.bin/make/hash.c
--- a/usr.bin/make/hash.c Sat Sep 05 13:41:00 2020 +0000
+++ b/usr.bin/make/hash.c Sat Sep 05 13:55:08 2020 +0000
@@ -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 @@
*
* 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
diff -r 075f583f0877 -r 8df04568f60a usr.bin/make/hash.h
--- a/usr.bin/make/hash.h Sat Sep 05 13:41:00 2020 +0000
+++ b/usr.bin/make/hash.h Sat Sep 05 13:55:08 2020 +0000
@@ -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 @@
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 *);
diff -r 075f583f0877 -r 8df04568f60a usr.bin/make/targ.c
--- a/usr.bin/make/targ.c Sat Sep 05 13:41:00 2020 +0000
+++ b/usr.bin/make/targ.c Sat Sep 05 13:55:08 2020 +0000
@@ -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 @@
Targ_Init(void)
{
allTargets = Lst_Init();
- Hash_InitTable(&targets, 191);
+ Hash_InitTable(&targets);
}
void
@@ -209,7 +209,7 @@
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;
Home |
Main Index |
Thread Index |
Old Index