From: Paul Eggert Date: Sat, 12 Jun 2021 00:18:57 +0000 (-0700) Subject: exclude: improve wide-character hashing X-Git-Tag: v1.0~2830 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=9e153bac1a7cb2d59e564a8631891b01658a6d5f;p=gnulib.git 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. --- 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 */