[Freeciv-Dev] Re: (PR#2521) general effects framework
[Top] [All Lists]
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
 
On Tue, Mar 11, 2003 at 08:28:53AM -0800, Mike Kaufman wrote:
> On Tue, Mar 11, 2003 at 07:48:17AM -0800, Raimar Falke wrote:
> > 
> > About what ints are you speaking here? BV uses unsigned char which should be
> > ok.
> 
> struct effect {
>   /* save a bunch of memory */
>   struct {
>     int active:1;      /* is effect active? */
>     int pending:1;     /* is effect active except for cond_bldg? */
>     int changed:1;     /* has effect changed since last update? */
>     int was_active:1;  /* temporary variable for calculation of 'changed' */
>   
>     int nat:1;         /* has req. nation (or doesn't need one) */
>     int adv:1;         /* has req. advance (or doesn't need one) */
>     int gov:1;         /* has req. gov (or doesn't need one) */
>     int bldg:1;        /* has req. bldg (only partially cached) */
>     int condeff:1;     /* has cond_eff (only partially cached) */
>     int no_equiv:1;    /* there is no equivalent bldg that suppresses */
>   } has;
>   
>   struct player *plr;
>   struct city *home;       /* NULL if effect has no location (origin) */
>   int id;                  /* id of thing generating effect */
>   
>   struct effect_defn *defn;  /* a pointer to the effect definition */
> };
> 
> those should be unsigned I think. I forgot that you haven't seen this yet. 
> It's been in my code for so long I'd forgotten when I'd included it.
> 
> obviously BV doesn't have his problem since it isn't a true bitfield
> persay.
Do you have numbers which show that this reduces the execution time?
Accessing them is not as cheap as you may think:
void g(int x)
{
  s.has.gov=x;
}
generates:
        movb 8(%ebp),%al
        andb $1,%al
        salb $6,%al
        movb s,%dl
        andb $191,%dl
        orb %al,%dl
        movb %dl,s
and
int g(void)
{
  return s.has.adv;
}
        movb s,%al
        salb $2,%al
        sarb $7,%al
        movsbl %al,%eax
A lot of instructions for an assignment. Using the bool type may increase
the cache pressure but may speed the execution up. I don't know which one is
faster but it isn't obvious to me that the bitfields are the better choice.
        Raimar
 
- [Freeciv-Dev] (PR#2521) general effects framework, Mike Kaufman, 2003/03/10
- Message not available
- [Freeciv-Dev] Re: (PR#2521) general effects framework, Raimar Falke, 2003/03/11
- [Freeciv-Dev] Re: (PR#2521) general effects framework, Mike Kaufman, 2003/03/11
 - [Freeciv-Dev] Re: (PR#2521) general effects framework, Raimar Falke, 2003/03/11
 - [Freeciv-Dev] Re: (PR#2521) general effects framework, Mike Kaufman, 2003/03/11
 - [Freeciv-Dev] Re: (PR#2521) general effects framework,
Raimar Falke <=
 - [Freeciv-Dev] Re: (PR#2521) general effects framework, Mike Kaufman, 2003/03/11
 - [Freeciv-Dev] Re: (PR#2521) general effects framework, Raimar Falke, 2003/03/11
 
- [Freeciv-Dev] Re: (PR#2521) general effects framework, rwetmore@xxxxxxxxxxxx, 2003/03/11
 - [Freeciv-Dev] Re: (PR#2521) general effects framework, Raimar Falke, 2003/03/12
 - [Freeciv-Dev] Re: (PR#2521) general effects framework, rwetmore@xxxxxxxxxxxx, 2003/03/12
 - [Freeciv-Dev] Re: (PR#2521) general effects framework, Raimar Falke, 2003/03/13
 
  
  
  
 
 
 | 
 |