Changeset 1902 for trunk/src/kmk/dir.c
- Timestamp:
- Oct 21, 2008, 5:57:00 AM (17 years ago)
- File:
-
- 1 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,
Note:
See TracChangeset
for help on using the changeset viewer.