Ignore:
Timestamp:
Oct 22, 2008, 8:49:48 PM (17 years ago)
Author:
bird
Message:

strcache2: Implemented collision resolution by chaining instead of open addressing. This is faster than the open addressing approach we're using.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kmk/strcache2.h

    r1908 r1909  
    3333
    3434#define STRCACHE2_USE_MASK 1
     35#define STRCACHE2_USE_CHAINING 1
    3536
    3637/* string cache memory segment. */
     
    4748struct strcache2_entry
    4849{
     50#ifdef STRCACHE2_USE_CHAINING
     51    struct strcache2_entry *next;       /* Collision chain. */
     52#endif
    4953    void *user;
    5054    unsigned int hash1;
     55#ifndef STRCACHE2_USE_CHAINING
    5156    unsigned int hash2;
     57#endif
    5258    unsigned int length;
    5359};
     
    8389    unsigned long collision_3rd_count;  /* The number of 3rd level collisions. */
    8490    unsigned int count;                 /* Number entries in the cache. */
     91#ifdef STRCACHE2_USE_CHAINING
     92    unsigned int collision_count;       /* Number of entries in chains. */
     93#endif
    8594    unsigned int rehash_count;          /* When to rehash the table. */
    8695    unsigned int init_size;             /* The initial hash table size. */
     
    146155}
    147156
     157#ifndef STRCACHE2_USE_CHAINING
    148158/* Get the second hash value for the string. */
    149159MY_INLINE unsigned int
     
    155165  return hash2;
    156166}
     167#endif
    157168
    158169/* Get the pointer hash value for the string.
Note: See TracChangeset for help on using the changeset viewer.