Complete.Org: Mailing Lists: Archives: freeciv-dev: October 2001:
[Freeciv-Dev] Re: PATCH: cleanup in fill_tile_sprite_array(PR#1016)
Home

[Freeciv-Dev] Re: PATCH: cleanup in fill_tile_sprite_array(PR#1016)

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: "Ross W. Wetmore" <rwetmore@xxxxxxxxxxxx>
Cc: jdorje@xxxxxxxxxxxx, freeciv-dev <freeciv-dev@xxxxxxxxxxx>
Subject: [Freeciv-Dev] Re: PATCH: cleanup in fill_tile_sprite_array(PR#1016)
From: Gaute B Strokkenes <gs234@xxxxxxxxx>
Date: Wed, 24 Oct 2001 05:49:01 +0100

On Tue, 23 Oct 2001, rwetmore@xxxxxxxxxxxx wrote:
> At 10:59 PM 01/10/21 -0400, Jason Dorje Short wrote:
>>"Ross W. Wetmore" wrote:
>>> In this case do the computation once and stash it in an array.
>>> Then do an array lookup.
>>
>>Do you have actual evidence that that is faster?  Several
>>comparisons are necessary to look up an index in an array, whereas
>>Raimar's code makes 4.5 comparisons to constant values (memory
>>positions) on average.
> 
> Huh? Where I come from an array lookup is a single load operation
> :-).

To be more precise, the traditional way to do it is to take the
address of the array and add the array index multiplied by the size of
each object in the array.  I don't know what Jason was thinking of.
The values being compared to in Raimar's version are not memory
locations either.

-- 
Big Gaute                               http://www.srcf.ucam.org/~gs234/
What GOOD is a CARDBOARD suitcase ANYWAY?


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