Complete.Org: Mailing Lists: Archives: freeciv-dev: August 2001:
[Freeciv-Dev] Re: Core code cleanups [Was: Profiling Civserveragain]
Home

[Freeciv-Dev] Re: Core code cleanups [Was: Profiling Civserveragain]

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Jason Dorje Short <jshort@xxxxxxxxxxxxx>
Cc: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: Core code cleanups [Was: Profiling Civserveragain]
From: Trent Piepho <xyzzy@xxxxxxxxxxxxx>
Date: Thu, 2 Aug 2001 13:43:05 -0700 (PDT)

On Thu, 2 Aug 2001, Jason Dorje Short wrote:
>     int y1 = y + DIR_DY2[dir];                   \
>     if (_border)                                 \
>       _valid = normalize_map_pos(&x1, &y1);      \
>     if (_valid) {                                \
> 
> #define adjc_all_iterate_invalid } else {
> 
> #define adjc_all_iterate_end  } } }

That seems a lot more complex and none of the other iterator macros are like
that.  And it requires that the code have two completely separate paths for
valid/invalid tiles.  For instance:

adjc_all_iterate(x,y, x1, y1, dir, valid) {
  do_something(x,y,dir);
  if(valid) something_else(x1,y1);
} adjc_all_iterate_end;

.vs.

adjc_all_iterate(x,y, x1, y1, dir)
  do_something(x,y,dir);
  something_else(x1,y1);
adjc_all_iterate_invalid
  do_something(x,y,dir);
adhc_all_iterate_end


Now if do_something() ends up being a dozen lines of code, it can make quite a
difference.

> On a separate note, I really don't think your DIR_DX[type][dir] arrays
> will work for a lot of wrapping systems that freeciv might like to use. 
> We're better off just calling normalize_map_pos.

I think the system can handle quite a few different types of map wrapping. 
And once you add all those types of wrapping into normalize_map_pos(), it's
going to become a very complex function.



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