Complete.Org: Mailing Lists: Archives: freeciv-dev: January 2004:
[Freeciv-Dev] Re: (PR#7229) Re: Re: Freeciv commit: ali: Add macro is_c
Home

[Freeciv-Dev] Re: (PR#7229) Re: Re: Freeciv commit: ali: Add macro is_c

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: a-l@xxxxxxx
Subject: [Freeciv-Dev] Re: (PR#7229) Re: Re: Freeciv commit: ali: Add macro is_city_hilited().
From: "Jason Short" <jshort@xxxxxxxxxxxxxx>
Date: Sat, 10 Jan 2004 12:52:26 -0800
Reply-to: rt@xxxxxxxxxxx

<URL: http://rt.freeciv.org/Ticket/Display.html?id=7229 >


> Although I've become used to it from Freeciv hacking, I would
> previously never have written something like this:
>
> {
>   if (same_pos(punit->x,
>                punit->y,
>                get_unit_in_focus()->x,    /* L1 */
>                get_unit_in_focus()->y)) {
>     ...
>   }
> }
>
> Instead I would've written:
> {
>   struct unit *focusunit = get_unit_in_focus();
>   if (same_pos(punit->x,
>                punit->y,
>                focusunit->x,    /* L1 */
>                focusunit->y)) {
>     ...
>   }
> }
>
> Do you expect a piece of silicon to generate an interrupt precisely
> at L1 which may change punit_focus via a GTK timer?

This is wrong on many levels.

1.  If the value ever were changed at L1, the first piece of code would be
wrong since it would use one unit's X value and another unit's Y value.

2.  Freeciv clients are single-threaded, so there will never be an
interrupt to change the value at L1.

3.  The second form is faster, but negligibly so (except in code that
"needs" optimization).  So it's really just a matter of style.  I much
prefer the second form.

jaosn





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