Changeset 1902 in kBuild
- Timestamp:
- Oct 21, 2008 3:57:00 AM (16 years ago)
- Location:
- trunk/src/kmk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kmk/dir.c
r1901 r1902 377 377 }; 378 378 379 #ifndef CONFIG_WITH_STRCACHE2 379 380 static unsigned long 380 381 directory_hash_1 (const void *key) 381 382 { 382 #ifndef CONFIG_WITH_STRCACHE2383 383 return_ISTRING_HASH_1 (((const struct directory *) key)->name); 384 #else385 return strcache2_get_ptr_hash (&file_strcache, ((const struct directory *) key)->name);386 #endif387 384 } 388 385 … … 390 387 directory_hash_2 (const void *key) 391 388 { 392 #ifndef CONFIG_WITH_STRCACHE2393 389 return_ISTRING_HASH_2 (((const struct directory *) key)->name); 394 #else395 return strcache2_get_hash1 (&file_strcache, ((const struct directory *) key)->name);396 #endif397 390 } 398 391 … … 400 393 directory_hash_cmp (const void *x, const void *y) 401 394 { 402 #ifndef CONFIG_WITH_STRCACHE2403 395 return_ISTRING_COMPARE (((const struct directory *) x)->name, 404 396 ((const struct directory *) y)->name); 405 #else 406 return ((const struct directory *) x)->name 407 == ((const struct directory *) y)->name ? 0 : -1; 408 #endif 409 } 397 } 398 #endif /* !CONFIG_WITH_STRCACHE2 */ 410 399 411 400 /* Table of directories hashed by name. */ … … 433 422 }; 434 423 424 #ifndef CONFIG_WITH_STRCACHE2 435 425 static unsigned long 436 426 dirfile_hash_1 (const void *key) 437 427 { 438 #ifndef CONFIG_WITH_STRCACHE2439 428 return_ISTRING_HASH_1 (((struct dirfile const *) key)->name); 440 #else441 return strcache2_get_ptr_hash (&file_strcache, ((struct dirfile const *) key)->name);442 #endif443 429 } 444 430 … … 446 432 dirfile_hash_2 (const void *key) 447 433 { 448 #ifndef CONFIG_WITH_STRCACHE2449 434 return_ISTRING_HASH_2 (((struct dirfile const *) key)->name); 450 #else451 return strcache2_get_hash1 (&file_strcache, ((struct dirfile const *) key)->name);452 #endif453 435 } 454 436 … … 458 440 const struct dirfile *x = xv; 459 441 const struct dirfile *y = yv; 460 #ifndef CONFIG_WITH_STRCACHE2461 442 int result = x->length - y->length; 462 443 if (result) 463 444 return result; 464 445 return_ISTRING_COMPARE (x->name, y->name); 465 #else 466 return x->name == y->name ? 0 : -1; 467 #endif 468 } 446 } 447 #endif /* !CONFIG_WITH_STRCACHE2 */ 469 448 470 449 #ifndef DIRFILE_BUCKETS … … 510 489 #ifndef CONFIG_WITH_STRCACHE2 511 490 dir_key.name = name; 491 dir_slot = (struct directory **) hash_find_slot (&directories, &dir_key); 512 492 #else 513 493 p = name + strlen (name); 514 494 dir_key.name = strcache_add_len (name, p - name); 515 #endif 516 dir_slot = (struct directory **) hash_find_slot (&directories, &dir_key); 495 dir_slot = (struct directory **) hash_find_slot_strcached (&directories, &dir_key); 496 #endif 517 497 dir = *dir_slot; 518 498 … … 657 637 if (buckets < DIRFILE_BUCKETS) 658 638 buckets = DIRFILE_BUCKETS; 659 hash_init (&dc->dirfiles, buckets, 660 dirfile_hash_1, dirfile_hash_2, dirfile_hash_cmp); 661 #else 639 hash_init_strcached (&dc->dirfiles, buckets, &file_strcache, 640 offsetof (struct dirfile, name)); 641 #else 642 # ifndef CONFIG_WITH_STRCACHE2 662 643 hash_init (&dc->dirfiles, DIRFILE_BUCKETS, 663 644 dirfile_hash_1, dirfile_hash_2, dirfile_hash_cmp); 645 # else /* CONFIG_WITH_STRCACHE2 */ 646 hash_init_strcached (&dc->dirfiles, DIRFILE_BUCKETS, 647 &file_strcache, 648 offsetof (struct dirfile, name)); 649 # endif /* CONFIG_WITH_STRCACHE2 */ 664 650 #endif 665 651 /* Keep track of how many directories are open. */ … … 730 716 dirfile_key.name = filename; 731 717 dirfile_key.length = strlen (filename); 718 df = hash_find_item (&dir->dirfiles, &dirfile_key); 732 719 #else /* CONFIG_WITH_STRCACHE2 */ 733 720 dirfile_key.length = strlen (filename); 734 721 dirfile_key.name = filename 735 722 = strcache_add_len (filename, dirfile_key.length); 723 df = hash_find_item_strcached (&dir->dirfiles, &dirfile_key); 736 724 #endif /* CONFIG_WITH_STRCACHE2 */ 737 df = hash_find_item (&dir->dirfiles, &dirfile_key);738 725 if (df) 739 726 return !df->impossible; … … 811 798 /* bird: end */ 812 799 if (errno) 813 fatal (NILF, "INTERNAL: readdir(%p): %s (filename=%s)\n", dir, strerror (errno), filename);800 fatal (NILF, "INTERNAL: readdir(%p): %s (filename=%s)\n", (void *)dir, strerror (errno), filename); 814 801 break; 815 802 } … … 829 816 #ifndef CONFIG_WITH_STRCACHE2 830 817 dirfile_key.name = d->d_name; 831 #else832 dirfile_key.name = strcache_add_len (d->d_name, len);833 #endif834 818 dirfile_key.length = len; 835 819 dirfile_slot = (struct dirfile **) hash_find_slot (&dir->dirfiles, &dirfile_key); 820 #else 821 dirfile_key.name = strcache_add_len (d->d_name, len); 822 dirfile_key.length = len; 823 dirfile_slot = (struct dirfile **) hash_find_slot_strcached (&dir->dirfiles, &dirfile_key); 824 #endif 836 825 #ifdef WINDOWS32 837 826 /* … … 1028 1017 if (dir->contents->dirfiles.ht_vec == 0) 1029 1018 { 1019 #ifndef CONFIG_WITH_STRCACHE2 1030 1020 hash_init (&dir->contents->dirfiles, DIRFILE_BUCKETS, 1031 1021 dirfile_hash_1, dirfile_hash_2, dirfile_hash_cmp); 1022 #else /* CONFIG_WITH_STRCACHE2 */ 1023 hash_init_strcached (&dir->contents->dirfiles, DIRFILE_BUCKETS, 1024 &file_strcache, offsetof (struct dirfile, name)); 1025 #endif /* CONFIG_WITH_STRCACHE2 */ 1032 1026 } 1033 1027 … … 1122 1116 dirfile_key.name = filename; 1123 1117 dirfile_key.length = strlen (filename); 1118 dirfile = hash_find_item (&dir->dirfiles, &dirfile_key); 1124 1119 #else 1125 1120 dirfile_key.length = strlen (filename); 1126 1121 dirfile_key.name = strcache_add_len (filename, dirfile_key.length); 1127 #endif 1128 dirfile = hash_find_item (&dir->dirfiles, &dirfile_key); 1122 dirfile = hash_find_item_strcached (&dir->dirfiles, &dirfile_key); 1123 #endif 1129 1124 if (dirfile) 1130 1125 return dirfile->impossible; … … 1398 1393 hash_init_directories (void) 1399 1394 { 1395 #ifndef CONFIG_WITH_STRCACHE2 1400 1396 hash_init (&directories, DIRECTORY_BUCKETS, 1401 1397 directory_hash_1, directory_hash_2, directory_hash_cmp); 1398 #else /* */ 1399 hash_init_strcached (&directories, DIRECTORY_BUCKETS, &file_strcache, 1400 offsetof (struct directory, name)); 1401 #endif /* */ 1402 1402 hash_init (&directory_contents, DIRECTORY_BUCKETS, 1403 1403 directory_contents_hash_1, directory_contents_hash_2, -
trunk/src/kmk/file.c
r1901 r1902 41 41 /* Hash table of files the makefile knows how to make. */ 42 42 43 #ifndef CONFIG_WITH_STRCACHE2 43 44 static unsigned long 44 45 file_hash_1 (const void *key) 45 46 { 46 #ifndef CONFIG_WITH_STRCACHE247 47 return_ISTRING_HASH_1 (((struct file const *) key)->hname); 48 #else /* CONFIG_WITH_STRCACHE2 */49 return strcache2_get_ptr_hash (&file_strcache, ((struct file const *) key)->hname);50 #endif /* CONFIG_WITH_STRCACHE2 */51 48 } 52 49 … … 54 51 file_hash_2 (const void *key) 55 52 { 56 #ifndef CONFIG_WITH_STRCACHE257 53 return_ISTRING_HASH_2 (((struct file const *) key)->hname); 58 #else /* CONFIG_WITH_STRCACHE2 */ 59 return strcache2_get_ptr_hash (&file_strcache, ((struct file const *) key)->hname); 60 #endif /* CONFIG_WITH_STRCACHE2 */ 61 } 54 } 55 #endif /* !CONFIG_WITH_STRCACHE2 */ 62 56 63 57 static int … … 148 142 file_key.hname = strcache2_lookup (&file_strcache, name, strlen (name)); 149 143 if (file_key.hname) 150 f = hash_find_item (&files, &file_key);144 f = hash_find_item_strcached (&files, &file_key); 151 145 else 152 146 f = NULL; … … 155 149 { 156 150 file_key.hname = name; 157 f = hash_find_item (&files, &file_key);151 f = hash_find_item_strcached (&files, &file_key); 158 152 } 159 153 … … 296 290 297 291 /* Remove the "from" file from the hash. */ 292 #ifndef CONFIG_WITH_STRCACHE2 298 293 deleted_file = hash_delete (&files, from_file); 294 #else 295 deleted_file = hash_delete_strcached (&files, from_file); 296 #endif 299 297 if (deleted_file != from_file) 300 298 /* from_file isn't the one stored in files */ … … 1343 1341 init_hash_files (void) 1344 1342 { 1345 #ifdef KMK 1343 #ifndef CONFIG_WITH_STRCACHE2 1344 # ifdef KMK 1346 1345 hash_init (&files, /*65535*/ 32755, file_hash_1, file_hash_2, file_hash_cmp); 1346 # else 1347 hash_init (&files, 1000, file_hash_1, file_hash_2, file_hash_cmp); 1348 # endif 1347 1349 #else 1348 hash_init (&files, 1000, file_hash_1, file_hash_2, file_hash_cmp); 1350 # ifdef KMK 1351 hash_init_strcached (&files, 32755, &file_strcache, 1352 offsetof (struct file, hname)); 1353 # else 1354 hash_init_strcached (&files, 1000, &file_strcache, 1355 offsetof (struct file, hname)); 1356 # endif 1349 1357 #endif 1350 1358 } -
trunk/src/kmk/hash.c
r1864 r1902 19 19 #include "make.h" 20 20 #include "hash.h" 21 #ifdef CONFIG_WITH_STRCACHE2 22 # include <assert.h> 23 #endif 24 21 25 22 26 #define CALLOC(t, n) ((t *) calloc (sizeof (t), (n))) … … 62 66 ht->ht_hash_2 = hash_2; 63 67 ht->ht_compare = hash_cmp; 64 } 68 #ifdef CONFIG_WITH_STRCACHE2 69 ht->ht_strcache = 0; 70 ht->ht_off_string = 0; 71 #endif 72 } 73 74 #ifdef CONFIG_WITH_STRCACHE2 75 /* Same as hash_init, except that no callbacks are needed since all 76 keys - including the ones being searched for - are from a string 77 cache. This means that any give string will only have one pointer 78 value and that the hash and length can be retrived very cheaply, 79 thus permitting some nice optimizations. 80 81 STRCACHE points to the string cache, while OFF_STRING gives the 82 offset of the string pointer in the item structures the hash table 83 entries points to. */ 84 void hash_init_strcached (struct hash_table *ht, unsigned long size, 85 struct strcache2 *strcache, unsigned int off_string) 86 { 87 hash_init (ht, size, 0, 0, 0); 88 ht->ht_strcache = strcache; 89 ht->ht_off_string = off_string; 90 } 91 #endif /* CONFIG_WITH_STRCACHE2 */ 65 92 66 93 /* Load an array of items into `ht'. */ … … 71 98 { 72 99 char *items = (char *) item_table; 100 #ifndef CONFIG_WITH_STRCACHE2 73 101 while (cardinality--) 74 102 { … … 76 104 items += size; 77 105 } 106 #else /* CONFIG_WITH_STRCACHE2 */ 107 if (ht->ht_strcache) 108 while (cardinality--) 109 { 110 hash_insert_strcached (ht, items); 111 items += size; 112 } 113 else 114 while (cardinality--) 115 { 116 hash_insert (ht, items); 117 items += size; 118 } 119 #endif /* CONFIG_WITH_STRCACHE2 */ 78 120 } 79 121 … … 90 132 unsigned int hash_2 = 0; 91 133 unsigned int hash_1 = (*ht->ht_hash_1) (key); 134 135 #ifdef CONFIG_WITH_STRCACHE2 136 assert (ht->ht_strcache == 0); 137 #endif 92 138 93 139 ht->ht_lookups++; … … 124 170 } 125 171 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). */ 172 #ifdef CONFIG_WITH_STRCACHE2 173 /* hash_find_slot version for tables created with hash_init_strcached. */ 132 174 void ** 133 hash_find_slot_prehashed (struct hash_table *ht, const void *key, 134 unsigned int hash_1, unsigned int hash_2) 175 hash_find_slot_strcached (struct hash_table *ht, const void *key) 135 176 { 136 177 void **slot; 137 178 void **deleted_slot = 0; 179 const char *str1 = *(const char **)((const char *)key + ht->ht_off_string); 180 const char *str2; 181 unsigned int hash_1 = strcache2_get_ptr_hash (ht->ht_strcache, str1); 182 unsigned int hash_2; 183 184 #ifdef CONFIG_WITH_STRCACHE2 185 assert (ht->ht_strcache != 0); 186 #endif 138 187 139 188 ht->ht_lookups++; … … 141 190 make_stats_ht_lookups++; 142 191 #endif 192 193 /* first iteration unrolled. */ 194 195 hash_1 &= (ht->ht_size - 1); 196 slot = &ht->ht_vec[hash_1]; 197 if (*slot == 0) 198 return slot; 199 if (*slot != hash_deleted_item) 200 { 201 str2 = *(const char **)((const char *)(*slot) + ht->ht_off_string); 202 if (str1 == str2) 203 return slot; 204 205 ht->ht_collisions++; 206 #ifdef CONFIG_WITH_MAKE_STATS 207 make_stats_ht_collisions++; 208 #endif 209 } 210 else 211 deleted_slot = slot; 212 213 /* the rest of the loop. */ 214 215 hash_2 = strcache2_get_hash1 (ht->ht_strcache, str1) | 1; 216 hash_1 += hash_2; 143 217 for (;;) 144 218 { … … 155 229 else 156 230 { 157 if (key == *slot) 231 str2 = *(const char **)((const char *)(*slot) + ht->ht_off_string); 232 if (str1 == str2) 158 233 return slot; 159 if ((*ht->ht_compare) (key, *slot) == 0) 160 return slot; 234 161 235 ht->ht_collisions++; 162 236 #ifdef CONFIG_WITH_MAKE_STATS … … 164 238 #endif 165 239 } 166 if (!hash_2) 167 hash_2 = (*ht->ht_hash_2) (key) | 1; 240 168 241 hash_1 += hash_2; 169 242 } 170 243 } 171 172 #endif /* CONFIG_WITH_VALUE_LENGTH */ 244 #endif /* CONFIG_WITH_STRCACHE2 */ 173 245 174 246 void * … … 178 250 return ((HASH_VACANT (*slot)) ? 0 : *slot); 179 251 } 252 253 #ifdef CONFIG_WITH_STRCACHE2 254 void * 255 hash_find_item_strcached (struct hash_table *ht, const void *key) 256 { 257 void **slot = hash_find_slot_strcached (ht, key); 258 return ((HASH_VACANT (*slot)) ? 0 : *slot); 259 } 260 #endif /* CONFIG_WITH_STRCACHE2 */ 180 261 181 262 void * … … 188 269 } 189 270 271 #ifdef CONFIG_WITH_STRCACHE2 272 void * 273 hash_insert_strcached (struct hash_table *ht, const void *item) 274 { 275 void **slot = hash_find_slot_strcached (ht, item); 276 const void *old_item = slot ? *slot : 0; 277 hash_insert_at (ht, item, slot); 278 return (void *)((HASH_VACANT (old_item)) ? 0 : old_item); 279 } 280 #endif /* CONFIG_WITH_STRCACHE2 */ 281 190 282 void * 191 283 hash_insert_at (struct hash_table *ht, const void *item, const void *slot) … … 203 295 { 204 296 hash_rehash (ht); 297 #ifdef CONFIG_WITH_STRCACHE2 298 if (ht->ht_strcache) 299 return (void *)hash_find_slot_strcached (ht, item); 300 #endif /* CONFIG_WITH_STRCACHE2 */ 205 301 return (void *) hash_find_slot (ht, item); 206 302 } … … 215 311 return hash_delete_at (ht, slot); 216 312 } 313 314 #ifdef CONFIG_WITH_STRCACHE2 315 void * 316 hash_delete_strcached (struct hash_table *ht, const void *item) 317 { 318 void **slot = hash_find_slot_strcached (ht, item); 319 return hash_delete_at (ht, slot); 320 } 321 #endif /* CONFIG_WITH_STRCACHE2 */ 217 322 218 323 void * … … 353 458 ht->ht_vec = (void **) CALLOC (struct token *, ht->ht_size); 354 459 460 #ifndef CONFIG_WITH_STRCACHE2 355 461 for (ovp = old_vec; ovp < &old_vec[old_ht_size]; ovp++) 356 462 { … … 361 467 } 362 468 } 469 #else /* CONFIG_WITH_STRCACHE2 */ 470 if (ht->ht_strcache) 471 for (ovp = old_vec; ovp < &old_vec[old_ht_size]; ovp++) 472 { 473 if (! HASH_VACANT (*ovp)) 474 { 475 void **slot = hash_find_slot_strcached (ht, *ovp); 476 *slot = *ovp; 477 } 478 } 479 else 480 for (ovp = old_vec; ovp < &old_vec[old_ht_size]; ovp++) 481 { 482 if (! HASH_VACANT (*ovp)) 483 { 484 void **slot = hash_find_slot (ht, *ovp); 485 *slot = *ovp; 486 } 487 } 488 #endif /* CONFIG_WITH_STRCACHE2 */ 363 489 ht->ht_empty_slots = ht->ht_size - ht->ht_fill; 364 490 free (old_vec); -
trunk/src/kmk/hash.h
r1864 r1902 54 54 hash_func_t ht_hash_2; /* secondary hash function */ 55 55 hash_cmp_func_t ht_compare; /* comparison function */ 56 #ifdef CONFIG_WITH_STRCACHE2 57 struct strcache2 *ht_strcache; /* the string cache pointer. */ 58 unsigned int ht_off_string; /* offsetof (struct key, string) */ 59 #endif 56 60 }; 57 61 … … 63 67 unsigned long cardinality, unsigned long size)); 64 68 void **hash_find_slot __P((struct hash_table *ht, void const *key)); 65 #ifdef CONFIG_WITH_VALUE_LENGTH66 void **hash_find_slot_prehashed __P((struct hash_table *ht, const void *key,67 unsigned int hash_1, unsigned int hash_2));68 #endif69 69 void *hash_find_item __P((struct hash_table *ht, void const *key)); 70 70 void *hash_insert __P((struct hash_table *ht, const void *item)); … … 84 84 void **hash_dump __P((struct hash_table *ht, void **vector_0, qsort_cmp_t compare)); 85 85 86 #ifdef CONFIG_WITH_STRCACHE2 87 void hash_init_strcached __P((struct hash_table *ht, unsigned long size, 88 struct strcache2 *strcache, unsigned int off_strptr)); 89 void **hash_find_slot_strcached __P((struct hash_table *ht, const void *key)); 90 void *hash_find_item_strcached __P((struct hash_table *ht, void const *key)); 91 void *hash_insert_strcached __P((struct hash_table *ht, const void *item)); 92 void *hash_delete_strcached __P((struct hash_table *ht, void const *item)); 93 #endif /* CONFIG_WITH_STRCACHE2 */ 94 86 95 extern void *hash_deleted_item; 87 96 #define HASH_VACANT(item) ((item) == 0 || (void *) (item) == hash_deleted_item) -
trunk/src/kmk/variable.c
r1897 r1902 110 110 /* Hash table of all global variable definitions. */ 111 111 112 #ifndef CONFIG_WITH_STRCACHE2 112 113 static unsigned long 113 114 variable_hash_1 (const void *keyv) 114 115 { 115 116 struct variable const *key = (struct variable const *) keyv; 116 #ifndef CONFIG_WITH_STRCACHE2117 117 return_STRING_N_HASH_1 (key->name, key->length); 118 #else119 /* all requests are served from the cache. */120 return strcache2_get_ptr_hash (&variable_strcache, key->name);121 #endif122 118 } 123 119 … … 126 122 { 127 123 struct variable const *key = (struct variable const *) keyv; 128 #ifndef CONFIG_WITH_STRCACHE2129 124 return_STRING_N_HASH_2 (key->name, key->length); 130 #else131 /* all requests are served from the cache. */132 return strcache2_get_hash2 (&variable_strcache, key->name);133 #endif134 125 } 135 126 … … 139 130 struct variable const *x = (struct variable const *) xv; 140 131 struct variable const *y = (struct variable const *) yv; 141 #ifndef CONFIG_WITH_STRCACHE2142 132 int result = x->length - y->length; 143 133 if (result) … … 145 135 146 136 return_STRING_N_COMPARE (x->name, y->name, x->length); 147 #else /* CONFIG_WITH_STRCACHE2 */ 148 149 /* everything is in the cache. */ 150 return x->name == y->name ? 0 : -1; 151 #endif /* CONFIG_WITH_STRCACHE2 */ 152 } 137 } 138 #endif /* !CONFIG_WITH_STRCACHE2 */ 153 139 154 140 #ifndef VARIABLE_BUCKETS … … 185 171 init_hash_global_variable_set (void) 186 172 { 173 #ifndef CONFIG_WITH_STRCACHE2 187 174 hash_init (&global_variable_set.table, VARIABLE_BUCKETS, 188 175 variable_hash_1, variable_hash_2, variable_hash_cmp); 189 # ifdef CONFIG_WITH_STRCACHE2176 #else /* CONFIG_WITH_STRCACHE2 */ 190 177 strcache2_init (&variable_strcache, "variable", 65536, 0, 0, 0); 191 #endif 178 hash_init_strcached (&global_variable_set.table, VARIABLE_BUCKETS, 179 &variable_strcache, offsetof (struct variable, name)); 180 #endif /* CONFIG_WITH_STRCACHE2 */ 192 181 } 193 182 … … 236 225 || !(v = strcache2_get_user_val (&variable_strcache, var_key.name))) 237 226 { 238 var_slot = (struct variable **) hash_find_slot (&set->table, &var_key);227 var_slot = (struct variable **) hash_find_slot_strcached (&set->table, &var_key); 239 228 v = *var_slot; 240 229 } … … 495 484 496 485 if (v == 0) 486 { 487 # ifndef NDEBUG 488 struct variable *v2 = (struct variable *) hash_find_item_strcached ((struct hash_table *) &setlist->set->table, &var_key); 489 assert (v2 == 0); 490 # endif 497 491 break; 492 } 498 493 if ((void *)v != hash_deleted_item) 499 494 { 500 if (v ariable_hash_cmp(&var_key, v) == 0)495 if (v->name == cached_name) 501 496 { 502 497 # ifndef NDEBUG 503 struct variable *v2 = (struct variable *) hash_find_item ((struct hash_table *) &setlist->set->table, &var_key);498 struct variable *v2 = (struct variable *) hash_find_item_strcached ((struct hash_table *) &setlist->set->table, &var_key); 504 499 assert (v2 == v); 505 500 # endif … … 509 504 } 510 505 if (!hash_2) 511 { 512 hash_2 = strcache2_get_hash2 (&variable_strcache, name); 513 assert (hash_2 & 1); 514 } 506 hash_2 = strcache2_get_hash1 (&variable_strcache, name) | 1; 515 507 hash_1 += hash_2; 516 508 } … … 520 512 struct variable *v; 521 513 514 # ifndef CONFIG_WITH_STRCACHE2 522 515 v = (struct variable *) hash_find_item ((struct hash_table *) &set->table, &var_key); 516 # else /* CONFIG_WITH_STRCACHE2 */ 517 v = (struct variable *) hash_find_item_strcached ((struct hash_table *) &set->table, &var_key); 518 # endif /* CONFIG_WITH_STRCACHE2 */ 523 519 if (v) 524 520 return v->special ? handle_special_var (v) : v; … … 596 592 { 597 593 struct variable var_key; 598 #ifdef CONFIG_WITH_STRCACHE2 594 #ifndef CONFIG_WITH_STRCACHE2 595 var_key.name = (char *) name; 596 var_key.length = length; 597 598 return (struct variable *) hash_find_item ((struct hash_table *) &set->table, &var_key); 599 #else /* CONFIG_WITH_STRCACHE2 */ 599 600 const char *cached_name; 600 601 … … 613 614 } 614 615 615 name = cached_name; 616 var_key.name = cached_name; 617 var_key.length = length; 618 619 return (struct variable *) hash_find_item_strcached ( 620 (struct hash_table *) &set->table, &var_key); 616 621 #endif /* CONFIG_WITH_STRCACHE2 */ 617 618 var_key.name = (char *) name;619 var_key.length = length;620 621 return (struct variable *) hash_find_item ((struct hash_table *) &set->table, &var_key);622 622 } 623 623 … … 643 643 xmalloc (sizeof (struct variable_set_list)); 644 644 l->set = xmalloc (sizeof (struct variable_set)); 645 #else 645 #else /* CONFIG_WITH_ALLOC_CACHES */ 646 646 l = (struct variable_set_list *) 647 647 alloccache_alloc (&variable_set_list_cache); 648 648 l->set = (struct variable_set *) 649 649 alloccache_alloc (&variable_set_cache); 650 #endif 650 #endif /* CONFIG_WITH_ALLOC_CACHES */ 651 #ifndef CONFIG_WITH_STRCACHE2 651 652 hash_init (&l->set->table, PERFILE_VARIABLE_BUCKETS, 652 653 variable_hash_1, variable_hash_2, variable_hash_cmp); 654 #else /* CONFIG_WITH_STRCACHE2 */ 655 hash_init_strcached (&l->set->table, PERFILE_VARIABLE_BUCKETS, 656 &variable_strcache, offsetof (struct variable, name)); 657 #endif /* CONFIG_WITH_STRCACHE2 */ 653 658 file->variables = l; 654 659 } … … 756 761 set = (struct variable_set *) alloccache_alloc (&variable_set_cache); 757 762 #endif 763 #ifndef CONFIG_WITH_STRCACHE2 758 764 hash_init (&set->table, SMALL_SCOPE_VARIABLE_BUCKETS, 759 765 variable_hash_1, variable_hash_2, variable_hash_cmp); 766 #else /* CONFIG_WITH_STRCACHE2 */ 767 hash_init_strcached (&set->table, SMALL_SCOPE_VARIABLE_BUCKETS, 768 &variable_strcache, offsetof (struct variable, name)); 769 #endif /* CONFIG_WITH_STRCACHE2 */ 760 770 761 771 #ifndef CONFIG_WITH_ALLOC_CACHES … … 878 888 struct variable *from_var = *from_var_slot; 879 889 struct variable **to_var_slot 890 #ifndef CONFIG_WITH_STRCACHE2 880 891 = (struct variable **) hash_find_slot (&to_set->table, *from_var_slot); 892 #else /* CONFIG_WITH_STRCACHE2 */ 893 = (struct variable **) hash_find_slot_strcached (&to_set->table, 894 *from_var_slot); 895 #endif /* CONFIG_WITH_STRCACHE2 */ 881 896 if (HASH_VACANT (*to_var_slot)) 882 897 hash_insert_at (&to_set->table, from_var, to_var_slot); … … 1296 1311 set_list = file->variables; 1297 1312 1313 #ifndef CONFIG_WITH_STRCACHE2 1298 1314 hash_init (&table, VARIABLE_BUCKETS, 1299 1315 variable_hash_1, variable_hash_2, variable_hash_cmp); 1316 #else /* CONFIG_WITH_STRCACHE2 */ 1317 hash_init_strcached (&table, VARIABLE_BUCKETS, 1318 &variable_strcache, offsetof (struct variable, name)); 1319 #endif /* CONFIG_WITH_STRCACHE2 */ 1300 1320 1301 1321 /* Run through all the variable sets in the list, … … 1368 1388 } 1369 1389 1390 #ifndef CONFIG_WITH_STRCACHE2 1370 1391 new_slot = (struct variable **) hash_find_slot (&table, v); 1392 #else /* CONFIG_WITH_STRCACHE2 */ 1393 new_slot = (struct variable **) hash_find_slot_strcached (&table, v); 1394 #endif /* CONFIG_WITH_STRCACHE2 */ 1371 1395 if (HASH_VACANT (*new_slot)) 1372 1396 hash_insert_at (&table, v, new_slot); … … 1381 1405 /* lookup the name in the string case, if it's not there it won't 1382 1406 be in any of the sets either. */ 1383 cached_name = strcache2_lookup (&variable_strcache,1384 MAKELEVEL_NAME, MAKELEVEL_LENGTH);1407 cached_name = strcache2_lookup (&variable_strcache, 1408 MAKELEVEL_NAME, MAKELEVEL_LENGTH); 1385 1409 if (cached_name) 1386 1410 { 1387 1411 makelevel_key.name = cached_name; 1388 1412 makelevel_key.length = MAKELEVEL_LENGTH; 1389 hash_delete (&table, &makelevel_key);1413 hash_delete_strcached (&table, &makelevel_key); 1390 1414 } 1391 1415 #endif /* CONFIG_WITH_STRCACHE2 */
Note:
See TracChangeset
for help on using the changeset viewer.