summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/ChangeLog4
-rw-r--r--lib/dynamicsizehash.c5
2 files changed, 7 insertions, 2 deletions
diff --git a/lib/ChangeLog b/lib/ChangeLog
index 6ce3168f..9b8899e2 100644
--- a/lib/ChangeLog
+++ b/lib/ChangeLog
@@ -1,3 +1,7 @@
+2013-12-12 Josh Stone <[email protected]>
+
+ * dynamicsizehash.c (lookup): Add a shortcut around division.
+
2013-04-30 Jan Kratochvil <[email protected]>
* eu-config.h (COMPAT_VERSION_NEWPROTO): New. Twice.
diff --git a/lib/dynamicsizehash.c b/lib/dynamicsizehash.c
index 40f48d5e..1fdff1b0 100644
--- a/lib/dynamicsizehash.c
+++ b/lib/dynamicsizehash.c
@@ -49,8 +49,9 @@ lookup (htab, hval, val)
HASHTYPE hval;
TYPE val __attribute__ ((unused));
{
- /* First hash function: simply take the modul but prevent zero. */
- size_t idx = 1 + hval % htab->size;
+ /* First hash function: simply take the modul but prevent zero. Small values
+ can skip the division, which helps performance when this is common. */
+ size_t idx = 1 + (hval < htab->size ? hval : hval % htab->size);
if (htab->table[idx].hashval != 0)
{