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: replace HashEntry_KeyEquals with strncmp



details:   https://anonhg.NetBSD.org/src/rev/7da959eedaeb
branches:  trunk
changeset: 359846:7da959eedaeb
user:      rillig <rillig%NetBSD.org@localhost>
date:      Thu Jan 27 10:45:36 2022 +0000

description:
make: replace HashEntry_KeyEquals with strncmp

No functional change.

diffstat:

 usr.bin/make/hash.c |  20 +++++---------------
 1 files changed, 5 insertions(+), 15 deletions(-)

diffs (48 lines):

diff -r 5318108d16e5 -r 7da959eedaeb usr.bin/make/hash.c
--- a/usr.bin/make/hash.c       Thu Jan 27 10:42:02 2022 +0000
+++ b/usr.bin/make/hash.c       Thu Jan 27 10:45:36 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: hash.c,v 1.69 2021/12/27 19:06:07 rillig Exp $ */
+/*     $NetBSD: hash.c,v 1.70 2022/01/27 10:45:36 rillig Exp $ */
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -74,7 +74,7 @@
 #include "make.h"
 
 /*     "@(#)hash.c     8.1 (Berkeley) 6/6/93"  */
-MAKE_RCSID("$NetBSD: hash.c,v 1.69 2021/12/27 19:06:07 rillig Exp $");
+MAKE_RCSID("$NetBSD: hash.c,v 1.70 2022/01/27 10:45:36 rillig Exp $");
 
 /*
  * The ratio of # entries to # buckets at which we rebuild the table to
@@ -133,18 +133,6 @@
        return e;
 }
 
-static bool
-HashEntry_KeyEquals(const HashEntry *he, Substring key)
-{
-       const char *heKey, *p;
-
-       heKey = he->key;
-       for (p = key.start; p != key.end; p++, heKey++)
-               if (*p != *heKey || *heKey == '\0')
-                       return false;
-       return *heKey == '\0';
-}
-
 static HashEntry *
 HashTable_FindEntryBySubstring(HashTable *t, Substring key, unsigned int h)
 {
@@ -158,7 +146,9 @@
 
        for (e = t->buckets[h & t->bucketsMask]; e != NULL; e = e->next) {
                chainlen++;
-               if (e->key_hash == h && HashEntry_KeyEquals(e, key))
+               if (e->key_hash == h &&
+                   strncmp(e->key, key.start, Substring_Length(key)) == 0 &&
+                   e->key[Substring_Length(key)] == '\0')
                        break;
        }
 



Home | Main Index | Thread Index | Old Index