Changeset 1858 in kBuild for trunk/src/kmk
- Timestamp:
- Oct 13, 2008 4:35:21 AM (16 years ago)
- Location:
- trunk/src/kmk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kmk/hash.c
r1700 r1858 123 123 } 124 124 } 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). */ 132 void ** 133 hash_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 */ 125 173 126 174 void * -
trunk/src/kmk/hash.h
r903 r1858 63 63 unsigned long cardinality, unsigned long size)); 64 64 void **hash_find_slot __P((struct hash_table *ht, void const *key)); 65 #ifdef CONFIG_WITH_VALUE_LENGTH 66 void **hash_find_slot_prehashed __P((struct hash_table *ht, const void *key, 67 unsigned int hash_1, unsigned int hash_2)); 68 #endif 65 69 void *hash_find_item __P((struct hash_table *ht, void const *key)); 66 70 void *hash_insert __P((struct hash_table *ht, const void *item)); -
trunk/src/kmk/strcache.c
r1857 r1858 164 164 str_hash_1 (const void *key) 165 165 { 166 #if 0 166 167 #ifdef CONFIG_WITH_VALUE_LENGTH 167 168 if (MY_PREDICT_TRUE ((const char *) key == lookup_string)) 168 169 return lookup_prefix->hash1; 170 #endif 169 171 #endif 170 172 return_ISTRING_HASH_1 ((const char *) key); … … 237 239 add_hash (const char *str, int len, unsigned long hash1, unsigned long hash2) 238 240 { 239 char *const*slot;241 void const **slot; 240 242 const char *key; 241 243 struct strcache_pref prefix; … … 251 253 lookup_prefix = &prefix; 252 254 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; 255 257 256 258 /* Count the total number of adds we performed. */
Note:
See TracChangeset
for help on using the changeset viewer.