Complete.Org: Mailing Lists: Archives: freeciv-dev: January 2004:
[Freeciv-Dev] (PR#7342) cm patch: heap-allocate the combinations
Home

[Freeciv-Dev] (PR#7342) cm patch: heap-allocate the combinations

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] (PR#7342) cm patch: heap-allocate the combinations
From: "Benoit Hudson" <bh@xxxxxxxxxxxxxxxxxxx>
Date: Thu, 29 Jan 2004 07:55:40 -0800
Reply-to: rt@xxxxxxxxxxx

<URL: http://rt.freeciv.org/Ticket/Display.html?id=7342 >

> [i-freeciv-lists@xxxxxxxxxxxxx - Thu Jan 29 09:12:53 2004]:
> 
> On Wed, Jan 28, 2004 at 07:12:17PM -0800, Benoit Hudson wrote:
> > 
> > <URL: http://rt.freeciv.org/Ticket/Display.html?id=7342 >
> > 
> > Right, and here's the promised patch.
> 
> What about runtime impact?

I covered that with "Doesn't seem to have any measurable impact
on running time."  I can run with profiling information if you want.


> Can't MAX_COMBINATIONS be removed then?

Probably.  I use it to make sure we're not runaway allocating huge
amounts of memory, but I'm not sure that's needed.

> > +#if SHOW_CM_STORAGE_USED
> > +static void report_cm_storage_used(void)
> > +{
> > +  int i, sum=0;
> > +  for(i=0; i<=MAX_FIELDS_USED; ++i) {
> > +    sum += cache3.results[i].ncombinations_allocated
> > +      * sizeof(struct combination*);
> > +    sum += cache3.results[i].ncombinations
> > +      * sizeof(struct combination);
> > +  }
> > +  sum += sizeof(cache3);
> > +  freelog(LOG_NORMAL, "CM: cache3 uses %d bytes", sum);
> > +  /* we should compute the cache1 and cache2 usage as well. */
> > +}
> > +#endif
> 
> > +#if SHOW_CM_STORAGE_USED
> > +  report_cm_storage_used();
> > +#endif
> 
> If you move the #if inside the function you only have the #if one
> time. IMHO better even if you call an empty function.

Sure.  I think even gcc is smart enough to optimize out the empty
function anyway.  I'll work out an updated patch later today, or tomorrow.
 
    -- Benoit


[Prev in Thread] Current Thread [Next in Thread]