Changeset 1858 for trunk/src/kmk/hash.c
- Timestamp:
- Oct 13, 2008, 6:35:21 AM (17 years ago)
- File:
-
- 1 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 *
Note:
See TracChangeset
for help on using the changeset viewer.