Skip to content

Commit

Permalink
Revert r1237078 partially: do not hash the hash.
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1237507 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
Bojan Smojver committed Jan 29, 2012
1 parent 598a57c commit e26e417
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions tables/apr_hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ APR_DECLARE(apr_hash_t *) apr_hash_make(apr_pool_t *pool)
ht->seed = (unsigned int)((now >> 32) ^ now ^ (apr_uintptr_t)pool ^
(apr_uintptr_t)ht ^ (apr_uintptr_t)&now) - 1;
ht->array = alloc_array(ht, ht->max);
ht->hash_func = apr_hashfunc_default;
ht->hash_func = NULL;

return ht;
}
Expand Down Expand Up @@ -289,10 +289,11 @@ static apr_hash_entry_t **find_entry(apr_hash_t *ht,
{
apr_hash_entry_t **hep, *he;
unsigned int hash;
apr_ssize_t hlen = sizeof(hash);

hash = ht->hash_func(key, &klen);
hash = hashfunc_default((char *)&hash, &hlen, ht->seed);
if (ht->hash_func)
hash = ht->hash_func(key, &klen);
else
hash = hashfunc_default(key, &klen, ht->seed);

/* scan linked list */
for (hep = &ht->array[hash & ht->max], he = *hep;
Expand Down Expand Up @@ -433,7 +434,6 @@ APR_DECLARE(apr_hash_t *) apr_hash_merge(apr_pool_t *p,
apr_hash_entry_t *iter;
apr_hash_entry_t *ent;
unsigned int i, j, k, hash;
apr_ssize_t hlen = sizeof(hash);

#if APR_POOL_DEBUG
/* we don't copy keys and values, so it's necessary that
Expand Down Expand Up @@ -483,8 +483,10 @@ APR_DECLARE(apr_hash_t *) apr_hash_merge(apr_pool_t *p,

for (k = 0; k <= overlay->max; k++) {
for (iter = overlay->array[k]; iter; iter = iter->next) {
hash = res->hash_func(iter->key, &iter->klen);
hash = hashfunc_default((char*)&hash, &hlen, res->seed);
if (res->hash_func)
hash = res->hash_func(iter->key, &iter->klen);
else
hash = hashfunc_default(iter->key, &iter->klen, res->seed);
i = hash & res->max;
for (ent = res->array[i]; ent; ent = ent->next) {
if ((ent->klen == iter->klen) &&
Expand Down

0 comments on commit e26e417

Please sign in to comment.