From little acorns: redo our string and digest hashing code to be faster, since this stuff may be critical-path.
svn:r11700
- Fix logic to look up a cert by its signing key digest. Bugfix on
0.2.0.7-alpha.
+ o Minor bugfixes (performance):
+ - Use a slightly simpler string hashing algorithm (copying Python's
+ instead of Java's) and optimize our digest hashing algorithm to take
+ advantage of 64-bit platforms and to remove some possibly-costly
+ voodoo.
+
+
Changes in version 0.2.0.7-alpha - 2007-09-21
o New directory authorities:
- Set up moria1 and tor26 as the first v3 directory authorities. See
static INLINE unsigned int
digestmap_entry_hash(const digestmap_entry_t *a)
{
- uint32_t *p = (uint32_t*)a->key;
- return ht_improve_hash(p[0] ^ p[1] ^ p[2] ^ p[3] ^ p[4]);
+#if SIZEOF_INT != 8
+ const uint32_t *p = (const uint32_t*)a->key;
+ return p[0] ^ p[1] ^ p[2] ^ p[3] ^ p[4];
+#else
+ const uint64_t *p = (const uint64_t*)a->key;
+ return p[0] ^ p[1];
+#endif
}
HT_PROTOTYPE(strmap_impl, strmap_entry_t, node, strmap_entry_hash,
return h;
}
+#if 0
/** Basic string hash function, from Java standard String.hashCode(). */
static INLINE unsigned
ht_string_hash(const char *s)
}
return h;
}
+#endif
+
+/** Basic string hash function, from Python's str.__hash__() */
+static INLINE unsigned
+ht_string_hash(const char *s)
+{
+ unsigned h;
+ const unsigned char *cp = (const unsigned char *)s;
+ h = *cp << 7;
+ while (*cp) {
+ h = (1000003*h) ^ *cp++;
+ }
+ h ^= (cp-(const unsigned char*)s);
+ return h;
+}
#define _HT_SET_HASH(elm, field, hashfn) \
(elm)->field.hte_hash = hashfn(elm)