VirtualBox

Changeset 1891 in kBuild for trunk/src/kmk/dir.c


Ignore:
Timestamp:
Oct 20, 2008 1:46:19 AM (16 years ago)
Author:
bird
Message:

kmk: dir.c - get hash values from the strcache and exploit it for comparing.

File:
1 edited

Legend:

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

    r1878 r1891  
    231231     * qualified name of the directory. Beware though, this is also
    232232     * unreliable. I'm open to suggestion on a better way to emulate inode.  */
     233# ifndef CONFIG_WITH_STRCACHE2
    233234    char *path_key;
     235# else
     236    char const *path_key; /* strcache'ed */
     237# endif
    234238    int   ctime;
    235239    int   mtime;        /* controls check for stale directory cache */
     
    256260
    257261#ifdef WINDOWS32
     262# ifndef CONFIG_WITH_STRCACHE2
    258263  hash = 0;
    259264  ISTRING_HASH_1 (key->path_key, hash);
     265# else  /* CONFIG_WITH_STRCACHE2 */
     266  hash = strcache_get_hash1 (key->path_key);
     267# endif /* CONFIG_WITH_STRCACHE2 */
    260268  hash ^= ((unsigned int) key->dev << 4) ^ (unsigned int) key->ctime;
    261269#else
     
    279287
    280288#ifdef WINDOWS32
     289# ifndef CONFIG_WITH_STRCACHE2
    281290  hash = 0;
    282291  ISTRING_HASH_2 (key->path_key, hash);
     292# else  /* CONFIG_WITH_STRCACHE2 */
     293  hash = strcache_get_hash2 (key->path_key);
     294# endif /* CONFIG_WITH_STRCACHE2 */
    283295  hash ^= ((unsigned int) key->dev << 4) ^ (unsigned int) ~key->ctime;
    284296#else
     
    315327
    316328#ifdef WINDOWS32
     329# ifndef CONFIG_WITH_STRCACHE2
    317330  ISTRING_COMPARE (x->path_key, y->path_key, result);
    318331  if (result)
    319332    return result;
     333# else  /* CONFIG_WITH_STRCACHE2 */
     334  if (x->path_key != y->path_key)
     335    return -1;
     336# endif /* CONFIG_WITH_STRCACHE2 */
    320337  result = MAKECMP(x->ctime, y->ctime);
    321338  if (result)
     
    363380directory_hash_1 (const void *key)
    364381{
     382#ifndef CONFIG_WITH_STRCACHE2
    365383  return_ISTRING_HASH_1 (((const struct directory *) key)->name);
     384#else
     385  return strcache_get_hash1 (((const struct directory *) key)->name);
     386#endif
    366387}
    367388
     
    369390directory_hash_2 (const void *key)
    370391{
     392#ifndef CONFIG_WITH_STRCACHE2
    371393  return_ISTRING_HASH_2 (((const struct directory *) key)->name);
     394#else
     395  return strcache_get_hash2 (((const struct directory *) key)->name);
     396#endif
    372397}
    373398
     
    375400directory_hash_cmp (const void *x, const void *y)
    376401{
     402#ifndef CONFIG_WITH_STRCACHE2
    377403  return_ISTRING_COMPARE (((const struct directory *) x)->name,
    378404                          ((const struct directory *) y)->name);
     405#else
     406  return ((const struct directory *) x)->name
     407      == ((const struct directory *) y)->name ? 0 : -1;
     408#endif
    379409}
    380410
     
    406436dirfile_hash_1 (const void *key)
    407437{
     438#ifndef CONFIG_WITH_STRCACHE2
    408439  return_ISTRING_HASH_1 (((struct dirfile const *) key)->name);
     440#else
     441  return strcache_get_hash1 (((struct dirfile const *) key)->name);
     442#endif
    409443}
    410444
     
    412446dirfile_hash_2 (const void *key)
    413447{
     448#ifndef CONFIG_WITH_STRCACHE2
    414449  return_ISTRING_HASH_2 (((struct dirfile const *) key)->name);
     450#else
     451  return strcache_get_hash2 (((struct dirfile const *) key)->name);
     452#endif
    415453}
    416454
     
    420458  const struct dirfile *x = xv;
    421459  const struct dirfile *y = yv;
     460#ifndef CONFIG_WITH_STRCACHE2
    422461  int result = x->length - y->length;
    423462  if (result)
    424463    return result;
    425464  return_ISTRING_COMPARE (x->name, y->name);
     465#else
     466  return x->name == y->name ? 0 : -1;
     467#endif
    426468}
    427469
     
    466508#endif
    467509
     510#ifndef CONFIG_WITH_STRCACHE2
    468511  dir_key.name = name;
     512#else
     513  p = name + strlen (name);
     514  dir_key.name = strcache_add_len (name, p - name);
     515#endif
    469516  dir_slot = (struct directory **) hash_find_slot (&directories, &dir_key);
    470517  dir = *dir_slot;
     
    476523      /* The directory was not found.  Create a new entry for it.  */
    477524
     525#ifndef CONFIG_WITH_STRCACHE2
    478526      p = name + strlen (name);
     527#endif
    479528#ifndef CONFIG_WITH_ALLOC_CACHES
    480529      dir = xmalloc (sizeof (struct directory));
     
    482531      dir = alloccache_alloc (&directories_cache);
    483532#endif
     533#ifndef CONFIG_WITH_STRCACHE2
    484534      dir->name = strcache_add_len (name, p - name);
     535#else
     536      dir->name = dir_key.name;
     537#endif
    485538      hash_insert_at (&directories, dir, dir_slot);
    486539      /* The directory is not in the name hash table.
     
    523576          dc_key.dev = st.st_dev;
    524577#ifdef WINDOWS32
     578# ifndef CONFIG_WITH_STRCACHE2
    525579          dc_key.path_key = w32_path = w32ify (name, 1);
     580# else  /* CONFIG_WITH_STRCACHE2 */
     581          w32_path = w32ify (name, 1);
     582          dc_key.path_key = strcache_add (w32_path);
     583# endif /* CONFIG_WITH_STRCACHE2 */
    526584          dc_key.ctime = st.st_ctime;
    527585#else
     
    552610              dc->dev = st.st_dev;
    553611#ifdef WINDOWS32
     612# ifndef CONFIG_WITH_STRCACHE2
    554613              dc->path_key = xstrdup (w32_path);
     614# else  /* CONFIG_WITH_STRCACHE2 */
     615              dc->path_key = dc_key.path_key;
     616# endif /* CONFIG_WITH_STRCACHE2 */
     617
    555618              dc->ctime = st.st_ctime;
    556619              dc->mtime = st.st_mtime;
     
    664727          return 1;
    665728        }
     729#ifndef CONFIG_WITH_STRCACHE2
    666730      dirfile_key.name = filename;
    667731      dirfile_key.length = strlen (filename);
     732#else  /* CONFIG_WITH_STRCACHE2 */
     733      dirfile_key.length = strlen (filename);
     734      dirfile_key.name = filename
     735        = strcache_add_len (filename, dirfile_key.length);
     736#endif /* CONFIG_WITH_STRCACHE2 */
    668737      df = hash_find_item (&dir->dirfiles, &dirfile_key);
    669738      if (df)
     
    758827
    759828      len = NAMLEN (d);
     829#ifndef CONFIG_WITH_STRCACHE2
    760830      dirfile_key.name = d->d_name;
     831#else
     832      dirfile_key.name = strcache_add_len (d->d_name, len);
     833#endif
    761834      dirfile_key.length = len;
    762835      dirfile_slot = (struct dirfile **) hash_find_slot (&dir->dirfiles, &dirfile_key);
     
    774847          df = alloccache_alloc (&dirfile_cache);
    775848#endif
     849#ifndef CONFIG_WITH_STRCACHE2
    776850          df->name = strcache_add_len (d->d_name, len);
     851#else
     852          df->name = dirfile_key.name;
     853#endif
    777854          df->length = len;
    778855          df->impossible = 0;
     
    780857        }
    781858      /* Check if the name matches the one we're searching for.  */
     859#ifndef CONFIG_WITH_STRCACHE2
    782860      if (filename != 0 && strieq (d->d_name, filename))
     861#else
     862      if (filename != 0 && dirfile_key.name == filename)
     863#endif
    783864        return 1;
    784865    }
     
    10381119#endif
    10391120
     1121#ifndef CONFIG_WITH_STRCACHE2
    10401122  dirfile_key.name = filename;
    10411123  dirfile_key.length = strlen (filename);
     1124#else
     1125  dirfile_key.length = strlen (filename);
     1126  dirfile_key.name = strcache_add_len (filename, dirfile_key.length);
     1127#endif
    10421128  dirfile = hash_find_item (&dir->dirfiles, &dirfile_key);
    10431129  if (dirfile)
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette