Complete.Org: Mailing Lists: Archives: freeciv-dev: February 2002:
[Freeciv-Dev] Re: client/tilespec.[ch] cleanup
Home

[Freeciv-Dev] Re: client/tilespec.[ch] cleanup

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: rf13@xxxxxxxxxxxxxxxxxxxxxx
Cc: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: client/tilespec.[ch] cleanup
From: Vasco Alexandre Da Silva Costa <vasc@xxxxxxxxxxxxxx>
Date: Thu, 7 Feb 2002 10:44:18 +0000 (WET)

On Thu, 7 Feb 2002, Raimar Falke wrote:

> On Wed, Feb 06, 2002 at 10:33:37PM +0000, Vasco Alexandre Da Silva Costa 
> wrote:
> > Hello,
> > 
> > I've cleaned this up a bit and removed the dir8_to_dir4() function.
> > My cleanup target was fill_tile_sprite_array_iso() so if you probably
> > should check that one out.
> > 
> > Comments?
> 
> > +    const int dirs[4][3] = {
> > +        /* up */
> > +        { DIR_CCW(DIR8_NORTHWEST), DIR8_NORTHWEST, DIR_CW(DIR8_NORTHWEST) 
> > },
> > +        /* down */
> > +        { DIR_CCW(DIR8_SOUTHEAST), DIR8_SOUTHEAST, DIR_CW(DIR8_SOUTHEAST) 
> > },
> > +        /* left */
> > +        { DIR_CCW(DIR8_SOUTHWEST), DIR8_SOUTHWEST, DIR_CW(DIR8_SOUTHWEST) 
> > },
> > +        /* right */
> > +        { DIR_CCW(DIR8_NORTHEAST), DIR8_NORTHEAST, DIR_CW(DIR8_NORTHEAST) }
> > +      };
> 
> Should be done in a loop. This will give shorter code which would be
> more clear on the intention.

I did it this way because its faster. All that stuff is constant, and if
the compiler is smart enough, it can be pre-calculated at compiler time.

I'll examine the assembler output at -O2 to see if gcc is smart enough.

> > -      SAFE_MAPSTEP(x1, y1, abs_x0, abs_y0, dir);
> 
> If you remove the last SAFE_MAPSTEP you can remove it altogether. You
> may move the SAFE_MAPSTEP definition into tilespec.c.

Hmmm. So no other places in the code use SAFE_MAPSTEP()? Then i guess i
can remove the last call and the macro can be deleted.

---
Vasco Alexandre da Silva Costa @ Instituto Superior Tecnico, Lisboa



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