Complete.Org: Mailing Lists: Archives: freeciv-dev: September 2004:
[Freeciv-Dev] Re: (PR#10128) improve eff building code
Home

[Freeciv-Dev] Re: (PR#10128) improve eff building code

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: per@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: (PR#10128) improve eff building code
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 15 Sep 2004 09:57:14 -0700
Reply-to: rt@xxxxxxxxxxx

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

Per I. Mathisen wrote:
> <URL: http://rt.freeciv.org/Ticket/Display.html?id=10128 >
> 
> On Wed, 15 Sep 2004, Jason Short wrote:
> 
>>Inlining city_want seems missplaced, since it calls 5 other functions
>>which themselves call numerous functions.
> 
> How does that make it misplaced?

The only reason to inline a function is to avoid function overhead cost. 
  However there is already function overhead of calling at least 5, and 
probably more like 10, functions.  So the benefit will be quite low.

>>You may be able to short-circuit it by skipping any entries that are 0.
> 
> What do you refer to here?

Replace

   want += ((shields * get_city_shield_bonus(acity)) / 100)
           * ai->shield_priority;

with

   if (shields != 0) {
     want += ((shields * get_city_shield_bonus(acity)) / 100)
             * ai->shield_priority;
   }

you may think that the compiler will optimize this.  But it can't 
because it doesn't know get_city_shield_bonus() has no side effects.

jason




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