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): make iterating over HashTable simpler



details:   https://anonhg.NetBSD.org/src/rev/b200547c96a0
branches:  trunk
changeset: 956432:b200547c96a0
user:      rillig <rillig%NetBSD.org@localhost>
date:      Fri Oct 30 16:48:58 2020 +0000

description:
make(1): make iterating over HashTable simpler

diffstat:

 usr.bin/make/arch.c |   9 ++++-----
 usr.bin/make/var.c  |  14 ++++++--------
 2 files changed, 10 insertions(+), 13 deletions(-)

diffs (84 lines):

diff -r 2095f68d4978 -r b200547c96a0 usr.bin/make/arch.c
--- a/usr.bin/make/arch.c       Fri Oct 30 16:45:37 2020 +0000
+++ b/usr.bin/make/arch.c       Fri Oct 30 16:48:58 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: arch.c,v 1.147 2020/10/25 19:19:07 rillig Exp $        */
+/*     $NetBSD: arch.c,v 1.148 2020/10/30 16:48:58 rillig Exp $        */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -130,7 +130,7 @@
 #include    "config.h"
 
 /*     "@(#)arch.c     8.2 (Berkeley) 1/2/94"  */
-MAKE_RCSID("$NetBSD: arch.c,v 1.147 2020/10/25 19:19:07 rillig Exp $");
+MAKE_RCSID("$NetBSD: arch.c,v 1.148 2020/10/30 16:48:58 rillig Exp $");
 
 #ifdef TARGET_MACHINE
 #undef MAKE_MACHINE
@@ -167,12 +167,11 @@
 {
     Arch *a = ap;
     HashIter hi;
-    HashEntry *he;
 
     /* Free memory from hash entries */
     HashIter_Init(&hi, &a->members);
-    while ((he = HashIter_Next(&hi)) != NULL)
-       free(HashEntry_Get(he));
+    while (HashIter_Next(&hi) != NULL)
+       free(hi.entry->value);
 
     free(a->name);
     free(a->fnametab);
diff -r 2095f68d4978 -r b200547c96a0 usr.bin/make/var.c
--- a/usr.bin/make/var.c        Fri Oct 30 16:45:37 2020 +0000
+++ b/usr.bin/make/var.c        Fri Oct 30 16:48:58 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: var.c,v 1.602 2020/10/30 16:45:37 rillig Exp $ */
+/*     $NetBSD: var.c,v 1.603 2020/10/30 16:48:58 rillig Exp $ */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -129,7 +129,7 @@
 #include    "metachar.h"
 
 /*     "@(#)var.c      8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.602 2020/10/30 16:45:37 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.603 2020/10/30 16:48:58 rillig Exp $");
 
 #define VAR_DEBUG1(fmt, arg1) DEBUG1(VAR, fmt, arg1)
 #define VAR_DEBUG2(fmt, arg1, arg2) DEBUG2(VAR, fmt, arg1, arg2)
@@ -602,12 +602,11 @@
 
     if (var_exportedVars == VAR_EXPORTED_ALL) {
        HashIter hi;
-       HashEntry *he;
 
        /* Ouch! Exporting all variables at once is crazy... */
        HashIter_Init(&hi, &VAR_GLOBAL->context);
-       while ((he = HashIter_Next(&hi)) != NULL) {
-           Var *var = HashEntry_Get(he);
+       while (HashIter_Next(&hi) != NULL) {
+           Var *var = hi.entry->value;
            Var_Export1(var->name, 0);
        }
        return;
@@ -3893,15 +3892,14 @@
 {
     Vector /* of const char * */ vec;
     HashIter hi;
-    HashEntry *he;
     size_t i;
     const char **varnames;
 
     Vector_Init(&vec, sizeof(const char *));
 
     HashIter_Init(&hi, &ctxt->context);
-    while ((he = HashIter_Next(&hi)) != NULL)
-       *(const char **)Vector_Push(&vec) = he->key;
+    while (HashIter_Next(&hi) != NULL)
+       *(const char **)Vector_Push(&vec) = hi.entry->key;
     varnames = vec.items;
 
     qsort(varnames, vec.len, sizeof varnames[0], str_cmp_asc);



Home | Main Index | Thread Index | Old Index