The hash function in the record key management system was improved and
the hash size was increased. This make this sub system approx 10
times faster as far as gprof is concerned. There _is_ a bigger overhead
with the 64-bit keys over Zebra's 32-bit keys, but not much.
-/* $Id: reckeys.c,v 1.4 2006-05-10 08:13:22 adam Exp $
- Copyright (C) 1995-2005
+/* $Id: reckeys.c,v 1.5 2006-05-22 13:28:00 adam Exp $
+ Copyright (C) 1995-2006
Index Data ApS
This file is part of the Zebra server.
Index Data ApS
This file is part of the Zebra server.
struct zebra_rec_key_entry **zebra_rec_keys_mk_hash(zebra_rec_keys_t p,
const char *buf,
struct zebra_rec_key_entry **zebra_rec_keys_mk_hash(zebra_rec_keys_t p,
const char *buf,
+ size_t len,
+ const struct it_key *key)
{
unsigned h = 0;
size_t i;
for (i = 0; i<len; i++)
h = h * 65509 + buf[i];
{
unsigned h = 0;
size_t i;
for (i = 0; i<len; i++)
h = h * 65509 + buf[i];
+ for (i = 0; i<key->len; i++)
+ h = h * 65509 + key->mem[i];
return &p->entries[h % (unsigned) p->hash_size];
}
return &p->entries[h % (unsigned) p->hash_size];
}
p->decode_handle = iscz1_start();
p->nmem = nmem_create();
p->decode_handle = iscz1_start();
p->nmem = nmem_create();
p->entries = 0;
init_hash(p);
p->entries = 0;
init_hash(p);
const char *str, size_t slen,
const struct it_key *key)
{
const char *str, size_t slen,
const struct it_key *key)
{
- struct zebra_rec_key_entry **kep = zebra_rec_keys_mk_hash(keys, str, slen);
+ struct zebra_rec_key_entry **kep = zebra_rec_keys_mk_hash(keys,
+ str, slen, key);
while (*kep)
{
struct zebra_rec_key_entry *e = *kep;
while (*kep)
{
struct zebra_rec_key_entry *e = *kep;