Module Name: src Committed By: rillig Date: Thu Jan 27 10:45:36 UTC 2022
Modified Files: src/usr.bin/make: hash.c Log Message: make: replace HashEntry_KeyEquals with strncmp No functional change. To generate a diff of this commit: cvs rdiff -u -r1.69 -r1.70 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.69 src/usr.bin/make/hash.c:1.70 --- src/usr.bin/make/hash.c:1.69 Mon Dec 27 19:06:07 2021 +++ src/usr.bin/make/hash.c Thu Jan 27 10:45:36 2022 @@ -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 @@ HashTable_Find(HashTable *t, unsigned in 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 @@ HashTable_FindEntryBySubstring(HashTable 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; }