From 9e153bac1a7cb2d59e564a8631891b01658a6d5f Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Fri, 11 Jun 2021 17:18:57 -0700 Subject: [PATCH] exclude: improve wide-character hashing * lib/exclude.c (string_hasher_ci): Take the modulo at the end rather than each time a wide character is retrieved; this should be more efficient and should hash better. --- ChangeLog | 7 +++++++ lib/exclude.c | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index d57d006ff5..304599f810 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2021-06-11 Paul Eggert + + exclude: improve wide-character hashing + * lib/exclude.c (string_hasher_ci): Take the modulo at the end + rather than each time a wide character is retrieved; this should + be more efficient and should hash better. + 2021-06-11 Bruno Haible Make message in last commit more precise. diff --git a/lib/exclude.c b/lib/exclude.c index 4ef4e08f13..6287fbc689 100644 --- a/lib/exclude.c +++ b/lib/exclude.c @@ -219,10 +219,10 @@ string_hasher_ci (void const *data, size_t n_buckets) else wc = *m.ptr; - value = (value * 31 + wc) % n_buckets; + value = value * 31 + wc; } - return value; + return value % n_buckets; } /* compare two strings for equality */ -- 2.39.5