[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] exclude: improve wide-character hashing
From: |
Paul Eggert |
Subject: |
[PATCH] exclude: improve wide-character hashing |
Date: |
Fri, 11 Jun 2021 17:20:54 -0700 |
* 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
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [PATCH] exclude: improve wide-character hashing,
Paul Eggert <=