Complete.Org: Mailing Lists: Archives: freeciv-dev: February 2002:
[Freeciv-Dev] Re: [Patch] Small patch
Home

[Freeciv-Dev] Re: [Patch] Small patch

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Gregory Berkolaiko <gberkolaiko@xxxxxxxxxxx>
Cc: freeciv development list <freeciv-dev@xxxxxxxxxxx>
Subject: [Freeciv-Dev] Re: [Patch] Small patch
From: Raimar Falke <hawk@xxxxxxxxxxxxxxxxxxxxxxx>
Date: Sun, 10 Feb 2002 20:12:06 +0100
Reply-to: rf13@xxxxxxxxxxxxxxxxxxxxxx

On Sun, Feb 10, 2002 at 06:49:10PM +0000, Gregory Berkolaiko wrote:
>  --- Raimar Falke <hawk@xxxxxxxxxxxxxxxxxxxxxxx> wrote: 
> 
> [...]
> >        \
> >    int ARG_x_itr, ARG_y_itr;                                           
> >        \
> >    int MACRO_max_dx = map.xsize/2;                                     
> >        \
> > -  int MACRO_min_dx = -(MACRO_max_dx - (map.xsize%2 ? 0 : 1));         
> >        \
> > +  int MACRO_min_dx = -MACRO_max_dx - 1 + (map.xsize % 2);             
> 
> performance issue: are you sure (map.xsize%2 ? 0 : 1) gets optimized?

No it doesn't. As I said: we can remove one jump.

> or maybe we can write (map.xsize & 1) to make sure about it?

signed int x;
unsigned int y;

"x%2" is

        movl    %edx, %eax
        shrl    $31, %eax
        leal    (%eax,%edx), %eax
        andl    $-2, %eax
        subl    %eax, %edx

while "y%2", "x&1" and "y&1" is

        andl    $1, %eax

So yes this may be optimized further.

        Raimar

-- 
 email: rf13@xxxxxxxxxxxxxxxxx
 "Sit, disk, sit. Good boy. Now spin up. Very good. Here's a netscape
  cookie for you. Fetch me some data. Come on, you can do it. No, not that
  data. Bad disk. Bad." 
    -- Calle Dybedahl, alt.sysadmin.recovery


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