VirtualBox

Changeset 1858 in kBuild for trunk/src/kmk


Ignore:
Timestamp:
Oct 13, 2008 4:35:21 AM (16 years ago)
Author:
bird
Message:

kmk: Added hash_find_slot_prehashed for the benefit of the strcache and includedep.

Location:
trunk/src/kmk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kmk/hash.c

    r1700 r1858  
    123123    }
    124124}
     125
     126#ifdef CONFIG_WITH_VALUE_LENGTH
     127/* A variant of hash_find_slot that takes the hash values as arguments.
     128   The HASH_2 argument is optional, pass 0 if not available.
     129   Not having to call ht_hash_1 and perhaps also not ht_hash_2 does save
     130   a whole bunch of cycles in some of the kBuild use cases (strcache sees
     131   serious usage there). */
     132void **
     133hash_find_slot_prehashed (struct hash_table *ht, const void *key,
     134                          unsigned int hash_1, unsigned int hash_2)
     135{
     136  void **slot;
     137  void **deleted_slot = 0;
     138
     139  ht->ht_lookups++;
     140#ifdef CONFIG_WITH_MAKE_STATS
     141  make_stats_ht_lookups++;
     142#endif
     143  for (;;)
     144    {
     145      hash_1 &= (ht->ht_size - 1);
     146      slot = &ht->ht_vec[hash_1];
     147
     148      if (*slot == 0)
     149        return (deleted_slot ? deleted_slot : slot);
     150      if (*slot == hash_deleted_item)
     151        {
     152          if (deleted_slot == 0)
     153            deleted_slot = slot;
     154        }
     155      else
     156        {
     157          if (key == *slot)
     158            return slot;
     159          if ((*ht->ht_compare) (key, *slot) == 0)
     160            return slot;
     161          ht->ht_collisions++;
     162#ifdef CONFIG_WITH_MAKE_STATS
     163          make_stats_ht_collisions++;
     164#endif
     165        }
     166      if (!hash_2)
     167          hash_2 = (*ht->ht_hash_2) (key) | 1;
     168      hash_1 += hash_2;
     169    }
     170}
     171
     172#endif /* CONFIG_WITH_VALUE_LENGTH */
    125173
    126174void *
  • trunk/src/kmk/hash.h

    r903 r1858  
    6363                    unsigned long cardinality, unsigned long size));
    6464void **hash_find_slot __P((struct hash_table *ht, void const *key));
     65#ifdef CONFIG_WITH_VALUE_LENGTH
     66void **hash_find_slot_prehashed __P((struct hash_table *ht, const void *key,
     67                                     unsigned int hash_1, unsigned int hash_2));
     68#endif
    6569void *hash_find_item __P((struct hash_table *ht, void const *key));
    6670void *hash_insert __P((struct hash_table *ht, const void *item));
  • trunk/src/kmk/strcache.c

    r1857 r1858  
    164164str_hash_1 (const void *key)
    165165{
     166#if 0
    166167#ifdef CONFIG_WITH_VALUE_LENGTH
    167168  if (MY_PREDICT_TRUE ((const char *) key == lookup_string))
    168169    return lookup_prefix->hash1;
     170#endif
    169171#endif
    170172  return_ISTRING_HASH_1 ((const char *) key);
     
    237239add_hash (const char *str, int len, unsigned long hash1, unsigned long hash2)
    238240{
    239   char *const *slot;
     241  void const **slot;
    240242  const char *key;
    241243  struct strcache_pref prefix;
     
    251253  lookup_prefix = &prefix;
    252254
    253   slot = (char *const *) hash_find_slot (&strings, str);
    254   key = *slot;
     255  slot = hash_find_slot_prehashed (&strings, str, prefix.hash1, prefix.hash2);
     256  key = *(const char **)slot;
    255257
    256258  /* Count the total number of adds we performed.  */
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette