Changeset 1862 for trunk/src/kmk/misc.c


Ignore:
Timestamp:
Oct 14, 2008, 3:04:03 AM (17 years ago)
Author:
bird
Message:

kmk: some preliminary allocation caching. seems dep, variables, variable sets and files would be good candidates for generic alloc caches.

File:
1 edited

Legend:

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

    r1859 r1862  
    712712/* Cache free struct dep to save time in free during snap_deps.
    713713   free is esp. slow on darwin for some reason. */
    714 static struct dep *free_deps;
     714static struct dep *free_deps = NULL;
     715static struct dep *free_deps_start = NULL;
     716static struct dep *free_deps_end = NULL;
    715717
    716718static struct dep *
    717719alloc_dep_int (void)
    718720{
    719     struct dep *d = free_deps;
    720     if (d)
    721       free_deps = d->next;
    722     else
    723       d = xmalloc (sizeof (struct dep));
    724     return d;
     721  struct dep *d = free_deps;
     722  if (MY_PREDICT_TRUE(d))
     723    free_deps = d->next;
     724  else if (free_deps_start != free_deps_end)
     725    d = free_deps_start++;
     726  else
     727    {
     728      /* allocate another chunk block. */
     729      free_deps_start = xmalloc (sizeof (struct dep) * 256);
     730      free_deps_end = free_deps_start + 256;
     731      d = free_deps_start++;
     732    }
     733  return d;
    725734}
    726735
Note: See TracChangeset for help on using the changeset viewer.