Complete.Org: Mailing Lists: Archives: freeciv-dev: March 2003:
[Freeciv-Dev] Re: (PR#2521) general effects framework
Home

[Freeciv-Dev] Re: (PR#2521) general effects framework

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients:;
Subject: [Freeciv-Dev] Re: (PR#2521) general effects framework
From: "Mike Kaufman" <kaufman@xxxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 11 Mar 2003 10:10:44 -0800
Reply-to: rt@xxxxxxxxxxxxxx

On Tue, Mar 11, 2003 at 08:51:22AM -0800, Raimar Falke wrote:
> 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.

hmm. well, right now the struct uses 4 bytes. switching to unsigned char
moves the number to 9 bytes (maybe 8 if can eliminate was_active).
If I use bool, I need 36 bytes. That's unacceptable. made fc_bool an
unsigned char and I'll use it. So for now, I'll change this to unsigned
char as speed here is important.

-mike



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