Module Name:    src
Committed By:   rillig
Date:           Sun Oct 25 18:03:59 UTC 2020

Modified Files:
        src/usr.bin/make: hash.c

Log Message:
make(1): refactor Hash_InitTable

First prepare all the data, then initialize the fields in declaration
order.


To generate a diff of this commit:
cvs rdiff -u -r1.49 -r1.50 src/usr.bin/make/hash.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/hash.c
diff -u src/usr.bin/make/hash.c:1.49 src/usr.bin/make/hash.c:1.50
--- src/usr.bin/make/hash.c:1.49	Sun Oct 25 17:58:53 2020
+++ src/usr.bin/make/hash.c	Sun Oct 25 18:03:59 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: hash.c,v 1.49 2020/10/25 17:58:53 rillig Exp $	*/
+/*	$NetBSD: hash.c,v 1.50 2020/10/25 18:03:59 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -79,7 +79,7 @@
 #include "make.h"
 
 /*	"@(#)hash.c	8.1 (Berkeley) 6/6/93"	*/
-MAKE_RCSID("$NetBSD: hash.c,v 1.49 2020/10/25 17:58:53 rillig Exp $");
+MAKE_RCSID("$NetBSD: hash.c,v 1.50 2020/10/25 18:03:59 rillig Exp $");
 
 /*
  * The ratio of # entries to # buckets at which we rebuild the table to
@@ -133,15 +133,15 @@ void
 Hash_InitTable(HashTable *t)
 {
 	unsigned int n = 16, i;
-	HashEntry **hp;
+	HashEntry **buckets = bmake_malloc(sizeof(*buckets) * n);
+	for (i = 0; i < n; i++)
+		buckets[i] = NULL;
 
-	t->numEntries = 0;
-	t->maxchain = 0;
+	t->buckets = buckets;
 	t->bucketsSize = n;
+	t->numEntries = 0;
 	t->bucketsMask = n - 1;
-	t->buckets = hp = bmake_malloc(sizeof(*hp) * n);
-	for (i = 0; i < n; i++)
-		hp[i] = NULL;
+	t->maxchain = 0;
 }
 
 /* Removes everything from the hash table and frees up the memory space it

Reply via email to