Changeset 1857 for trunk/src/kmk/make.h


Ignore:
Timestamp:
Oct 13, 2008, 5:58:07 AM (17 years ago)
Author:
bird
Message:

kmk: improved the hashing of file table entries by making the strcache cache their hash values along with the string length.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kmk/make.h

    r1854 r1857  
    511511#endif
    512512#ifdef CONFIG_WITH_VALUE_LENGTH
     513struct strcache_pref
     514{
     515    unsigned long hash1;
     516    unsigned long hash2;
     517    unsigned int len;
     518};
     519
     520int strcache_check_sanity (const char *str);
     521unsigned long strcache_get_hash2_fallback (const char *str);
     522
    513523MY_INLINE unsigned int strcache_get_len (const char *str)
    514524{
    515   unsigned int len = ((unsigned int *)str)[-1];
    516   MY_ASSERT_MSG (strcache_iscached (str), ("\n"));
    517   MY_ASSERT_MSG (strlen (str) == len, ("\n"));
     525  struct strcache_pref const *prefix = (struct strcache_pref const *)str - 1;
     526  unsigned int len = prefix->len;
     527  MY_ASSERT_MSG (strcache_check_sanity (str) == 0, ("!\n"));
    518528  return len;
    519529}
     530
     531MY_INLINE unsigned int strcache_get_hash1 (const char *str)
     532{
     533  struct strcache_pref const *prefix = (struct strcache_pref const *)str - 1;
     534  unsigned long hash1 = prefix->hash1;
     535  MY_ASSERT_MSG (strcache_check_sanity (str) == 0, ("!\n"));
     536  return hash1;
     537}
     538
     539MY_INLINE unsigned long strcache_get_hash2 (const char *str)
     540{
     541  struct strcache_pref const *prefix = (struct strcache_pref const *)str - 1;
     542  unsigned long hash2 = prefix->hash2;
     543  MY_ASSERT_MSG (strcache_check_sanity (str) == 0, ("!\n"));
     544  if (!hash2)
     545    return strcache_get_hash2_fallback (str);
     546  return hash2;
     547}
     548
    520549#endif
    521550
Note: See TracChangeset for help on using the changeset viewer.