VirtualBox

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


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

kmk: Use allocation caches for the tiny structs in dir.c (three caches / structs).

File:
1 edited

Legend:

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

    r1794 r1878  
    345345static struct hash_table directory_contents;
    346346
     347#ifdef CONFIG_WITH_ALLOC_CACHES
     348/* Allocation cache for directory contents. */
     349struct alloccache directory_contents_cache;
     350#endif
     351
    347352struct directory
    348353  {
     
    376381/* Table of directories hashed by name.  */
    377382static struct hash_table directories;
     383
     384#ifdef CONFIG_WITH_ALLOC_CACHES
     385/* Allocation cache for directories. */
     386struct alloccache directories_cache;
     387#endif
    378388
    379389/* Never have more than this many directories open at once.  */
     
    420430#endif
    421431
     432#ifdef CONFIG_WITH_ALLOC_CACHES
     433/* Allocation cache for dirfiles. */
     434struct alloccache dirfile_cache;
     435#endif
     436
     437
    422438
    423439static int dir_contents_file_exists_p (struct directory_contents *dir,
     
    461477
    462478      p = name + strlen (name);
     479#ifndef CONFIG_WITH_ALLOC_CACHES
    463480      dir = xmalloc (sizeof (struct directory));
     481#else
     482      dir = alloccache_alloc (&directories_cache);
     483#endif
    464484      dir->name = strcache_add_len (name, p - name);
    465485      hash_insert_at (&directories, dir, dir_slot);
     
    521541              /* Nope; this really is a directory we haven't seen before.  */
    522542
     543#ifndef CONFIG_WITH_ALLOC_CACHES
    523544              dc = (struct directory_contents *)
    524545                xmalloc (sizeof (struct directory_contents));
     546#else
     547              dc = (struct directory_contents *)
     548                    alloccache_alloc (&directory_contents_cache);
     549#endif
    525550
    526551              /* Enter it in the contents hash table.  */
     
    744769#endif
    745770        {
     771#ifndef CONFIG_WITH_ALLOC_CACHES
    746772          df = xmalloc (sizeof (struct dirfile));
     773#else
     774          df = alloccache_alloc (&dirfile_cache);
     775#endif
    747776          df->name = strcache_add_len (d->d_name, len);
    748777          df->length = len;
     
    907936      /* The directory could not be stat'd.  We allocate a contents
    908937         structure for it, but leave it out of the contents hash table.  */
     938#ifndef CONFIG_WITH_ALLOC_CACHES
    909939      dir->contents = xmalloc (sizeof (struct directory_contents));
     940#else
     941      dir->contents = alloccache_alloc (&directory_contents_cache);
     942#endif
    910943      memset (dir->contents, '\0', sizeof (struct directory_contents));
     944
    911945    }
    912946
     
    919953  /* Make a new entry and put it in the table.  */
    920954
     955#ifndef CONFIG_WITH_ALLOC_CACHES
    921956  new = xmalloc (sizeof (struct dirfile));
     957#else
     958  new = alloccache_alloc (&dirfile_cache);
     959#endif
    922960  new->length = strlen (filename);
    923961  new->name = strcache_add_len (filename, new->length);
     
    12791317             directory_contents_hash_1, directory_contents_hash_2,
    12801318             directory_contents_hash_cmp);
    1281 }
     1319#ifdef CONFIG_WITH_ALLOC_CACHES
     1320  alloccache_init (&directories_cache, sizeof (struct directory),
     1321                   "directories", NULL, NULL);
     1322  alloccache_init (&directory_contents_cache, sizeof (struct directory_contents),
     1323                   "directory_contents", NULL, NULL);
     1324  alloccache_init (&dirfile_cache, sizeof (struct dirfile),
     1325                   "dirfile", NULL, NULL);
     1326#endif
     1327}
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