summaryrefslogtreecommitdiff
path: root/src/common/container.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2014-02-07 17:38:16 -0500
committerNick Mathewson <nickm@torproject.org>2014-02-12 11:32:10 -0500
commit0e97c8e23e2572c14dd0f4f4fbfca77ee8a48be2 (patch)
treea9d0e1914c9bf8e136486ca02658029273e86be5 /src/common/container.c
parentf05820531a1e4bc5935609900f0067b2643f0529 (diff)
downloadtor-0e97c8e23e2572c14dd0f4f4fbfca77ee8a48be2.tar.gz
tor-0e97c8e23e2572c14dd0f4f4fbfca77ee8a48be2.zip
Siphash-2-4 is now our hash in nearly all cases.
I've made an exception for cases where I'm sure that users can't influence the inputs. This is likely to cause a slowdown somewhere, but it's safer to siphash everything and *then* look for cases to optimize. This patch doesn't actually get us any _benefit_ from siphash yet, since we don't really randomize the key at any point.
Diffstat (limited to 'src/common/container.c')
-rw-r--r--src/common/container.c10
1 files changed, 2 insertions, 8 deletions
diff --git a/src/common/container.c b/src/common/container.c
index 476dc82913..f489430ca4 100644
--- a/src/common/container.c
+++ b/src/common/container.c
@@ -1004,7 +1004,7 @@ strmap_entries_eq(const strmap_entry_t *a, const strmap_entry_t *b)
static INLINE unsigned int
strmap_entry_hash(const strmap_entry_t *a)
{
- return ht_string_hash(a->key);
+ return (unsigned) siphash24g(a->key, strlen(a->key));
}
/** Helper: compare digestmap_entry_t objects by key value. */
@@ -1018,13 +1018,7 @@ digestmap_entries_eq(const digestmap_entry_t *a, const digestmap_entry_t *b)
static INLINE unsigned int
digestmap_entry_hash(const digestmap_entry_t *a)
{
-#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
+ return (unsigned) siphash24g(a->key, DIGEST_LEN);
}
HT_PROTOTYPE(strmap_impl, strmap_entry_t, node, strmap_entry_hash,