[Bf-committers] Layer system

Martin Poirier theeth at yahoo.com
Fri Dec 21 23:48:29 CET 2007


--- David Bryant <aceone at bellsouth.net> wrote:

> I use bitfields in my patch but making bitfield
> arraysI'im unsure.Give a 
> code example.I need to understand.

int isOnLayers(int *obLayers, int *checkLayers)
{
    int i;
    for( i = 0; i < NB_LAYER_BLOCKS; i++)
    {
        if (obLayers[i] & checkLayers[i])
            return 1;
    }
    return 0;
}

With any decent compiler that loop is unrolled
(NB_LAYER_BLOCKS is constant) and with luck combines
multiple blocks in a scalar instruction (SSE*).

That's pretty much the equivalent of just using a
larger data type, without limits to the number of bits
in the field.

Martin


      ____________________________________________________________________________________
Looking for last minute shopping deals?  
Find them fast with Yahoo! Search.  http://tools.search.yahoo.com/newsearch/category.php?category=shopping


More information about the Bf-committers mailing list