Changeset 1885 for trunk/src/kmk/strcache2.c
- Timestamp:
- Oct 19, 2008, 11:30:02 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kmk/strcache2.c
r1879 r1885 61 61 62 62 63 /******************************************************************************* 64 * Global Variables * 65 *******************************************************************************/ 66 /* List of initialized string caches. */ 67 static struct strcache2 *strcache_head; 68 63 69 64 70 … … 375 381 struct strcache2_entry const *entry; 376 382 unsigned int hash2; 377 unsigned int hash1 = cache->case_insensitive 378 ? strcache2_case_insensitive_hash_1 (str, length) 379 : strcache2_case_sensitive_hash_1 (str, length); 383 unsigned int hash1 = strcache2_case_sensitive_hash_1 (str, length); 380 384 unsigned int idx; 385 386 assert (!cache->case_insensitive); 387 381 388 382 389 cache->lookup_count++; … … 394 401 cache->collision_1st_count++; 395 402 396 hash2 = cache->case_insensitive 397 ? strcache2_case_insensitive_hash_2 (str, length) 398 : strcache2_case_sensitive_hash_2 (str, length); 403 hash2 = strcache2_case_sensitive_hash_2 (str, length); 399 404 idx += hash2; 400 405 idx &= cache->hash_mask; … … 489 494 } 490 495 496 #if defined(HAVE_CASE_INSENSITIVE_FS) 497 498 /* The public add/lookup string interface for case insensitive strings. */ 499 const char * 500 strcache2_iadd (struct strcache2 *cache, const char *str, unsigned int length) 501 { 502 struct strcache2_entry const *entry; 503 unsigned int hash2; 504 unsigned int hash1 = strcache2_case_insensitive_hash_1 (str, length); 505 unsigned int idx; 506 507 assert (cache->case_insensitive); 508 cache->lookup_count++; 509 510 /* Lookup the entry in the hash table, hoping for an 511 early match. */ 512 idx = hash1 & cache->hash_mask; 513 entry = cache->hash_tab[idx]; 514 if (strcache2_is_equal (cache, entry, str, length, hash1)) 515 return (const char *)(entry + 1); 516 if (!entry) 517 hash2 = 0; 518 else 519 { 520 cache->collision_1st_count++; 521 522 hash2 = strcache2_case_insensitive_hash_2 (str, length); 523 idx += hash2; 524 idx &= cache->hash_mask; 525 entry = cache->hash_tab[idx]; 526 if (strcache2_is_equal (cache, entry, str, length, hash1)) 527 return (const char *)(entry + 1); 528 529 if (entry) 530 { 531 cache->collision_2nd_count++; 532 do 533 { 534 idx += hash2; 535 idx &= cache->hash_mask; 536 entry = cache->hash_tab[idx]; 537 cache->collision_3rd_count++; 538 if (strcache2_is_equal (cache, entry, str, length, hash1)) 539 return (const char *)(entry + 1); 540 } 541 while (entry); 542 } 543 } 544 545 /* Not found, add it at IDX. */ 546 return strcache2_enter_string (cache, idx, str, length, hash1, hash2); 547 } 548 549 /* strcache_ilookup later */ 550 551 #endif /* HAVE_CASE_INSENSITIVE_FS */ 552 491 553 /* Is the given string cached? returns 1 if it is, 0 if it isn't. */ 492 554 int … … 591 653 592 654 593 /* List of initialized string caches. */594 static struct strcache2 *strcache_head;595 655 596 656 /* Initalizes a new cache. */
Note:
See TracChangeset
for help on using the changeset viewer.