Bug#179385: patch: bigger hash table in main/filesdb.c
Package: dpkg
Version: 1.10.9
Tags: patch
This trivial patch increases the hash table size and changes the
factor in the hashing function in main/filesdb.c. For me it has the
effect of speeding up `dpkg-query -S /usr/bin/dpkg' by a factor of
2.8 or so.
Sami
--- dpkg-1.10.9-orig/main/filesdb.c 2002-08-30 00:44:43.000000000 +0300
+++ dpkg-1.10.9/main/filesdb.c 2003-02-02 00:52:50.000000000 +0200
@@ -520,7 +520,7 @@
int nbinn;
};
-#define BINS (1 << 13)
+#define BINS (1 << 17)
/* This must always be a power of two. If you change it
* consider changing the per-character hashing factor (currently
* 1785 = 137*13) too.
@@ -566,7 +566,7 @@
static int hash(const char *name) {
int v= 0;
- while (*name) { v *= 1785; v += *name; name++; }
+ while (*name) { v *= 1787; v += *name; name++; }
return v;
}
Reply to: