* [PATCH] exclude: improve wide-character hashing
@ 2021-06-12 0:20 Paul Eggert
0 siblings, 0 replies; only message in thread
From: Paul Eggert @ 2021-06-12 0:20 UTC (permalink / raw)
To: bug-gnulib; +Cc: Paul Eggert
* 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 d57d006ff..304599f81 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2021-06-11 Paul Eggert <eggert@cs.ucla.edu>
+
+ 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 <bruno@clisp.org>
Make message in last commit more precise.
diff --git a/lib/exclude.c b/lib/exclude.c
index 4ef4e08f1..6287fbc68 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.30.2
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2021-06-12 0:21 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-12 0:20 [PATCH] exclude: improve wide-character hashing Paul Eggert
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).