Changeset 1902 for trunk/src/kmk/file.c


Ignore:
Timestamp:
Oct 21, 2008, 5:57:00 AM (17 years ago)
Author:
bird
Message:

kmk: Moved the strcache hash optimizations into the hash code.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kmk/file.c

    r1901 r1902  
    4141/* Hash table of files the makefile knows how to make.  */
    4242
     43#ifndef CONFIG_WITH_STRCACHE2
    4344static unsigned long
    4445file_hash_1 (const void *key)
    4546{
    46 #ifndef CONFIG_WITH_STRCACHE2
    4747  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 */
    5148}
    5249
     
    5451file_hash_2 (const void *key)
    5552{
    56 #ifndef CONFIG_WITH_STRCACHE2
    5753  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 */
    6256
    6357static int
     
    148142      file_key.hname = strcache2_lookup (&file_strcache, name, strlen (name));
    149143      if (file_key.hname)
    150         f = hash_find_item (&files, &file_key);
     144        f = hash_find_item_strcached (&files, &file_key);
    151145      else
    152146        f = NULL;
     
    155149    {
    156150      file_key.hname = name;
    157       f = hash_find_item (&files, &file_key);
     151      f = hash_find_item_strcached (&files, &file_key);
    158152    }
    159153
     
    296290
    297291  /* Remove the "from" file from the hash.  */
     292#ifndef CONFIG_WITH_STRCACHE2
    298293  deleted_file = hash_delete (&files, from_file);
     294#else
     295  deleted_file = hash_delete_strcached (&files, from_file);
     296#endif
    299297  if (deleted_file != from_file)
    300298    /* from_file isn't the one stored in files */
     
    13431341init_hash_files (void)
    13441342{
    1345 #ifdef KMK
     1343#ifndef CONFIG_WITH_STRCACHE2
     1344# ifdef KMK
    13461345  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
    13471349#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
    13491357#endif
    13501358}
Note: See TracChangeset for help on using the changeset viewer.