[PATCH] dix: Simpler and faster XID hash

Keith Packard keithp at keithp.com
Wed Jan 19 19:44:47 PST 2011


On Wed, 19 Jan 2011 19:58:01 -0500, Adam Jackson <ajax at redhat.com> wrote:

> -    id &= RESOURCE_ID_MASK;
> -    switch (clientTable[client].hashsize)
> -    {
> -	case 6:
> -	    return ((int)(0x03F & (id ^ (id>>6) ^ (id>>12))));
> -	case 7:
> -	    return ((int)(0x07F & (id ^ (id>>7) ^ (id>>13))));
> -	case 8:
> -	    return ((int)(0x0FF & (id ^ (id>>8) ^ (id>>16))));
> -	case 9:
> -	    return ((int)(0x1FF & (id ^ (id>>9))));
> -	case 10:
> -	    return ((int)(0x3FF & (id ^ (id>>10))));
> -	case 11:
> -	    return ((int)(0x7FF & (id ^ (id>>11))));
> -    }
> -    return -1;
> +    return id & (clientTable[client].hashsize - 1);

This makes no sense to me. Did you meak (id & ((1 << hashsize) - 1) ?

(in which case, hashsize might want to be precomputed as 'hashmask' or
some such.

-- 
keith.packard at intel.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.x.org/archives/xorg-devel/attachments/20110119/2d12c1f3/attachment-0001.pgp>


More information about the xorg-devel mailing list