[PATCH 1/5] resource: Remove a useless iteration

Daniel Stone daniel at fooishbar.org
Mon Jan 10 07:02:20 PST 2011


Hi,

On Fri, Jan 07, 2011 at 02:27:25PM -0500, Adam Jackson wrote:
>  dix/resource.c |    5 ++---
>  1 files changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/dix/resource.c b/dix/resource.c
> index 6bd2403..07fcc65 100644
> --- a/dix/resource.c
> +++ b/dix/resource.c
> @@ -382,7 +382,6 @@ GetXIDRange(int client, Bool server, XID *minp, XID *maxp)
>      XID id, maxid;
>      ResourcePtr *resp;
>      ResourcePtr res;
> -    int i;
>      XID goodid;
>  
>      id = (Mask)client << CLIENTOFFSET;
> @@ -390,8 +389,8 @@ GetXIDRange(int client, Bool server, XID *minp, XID *maxp)
>  	id |= client ? SERVER_BIT : SERVER_MINID;
>      maxid = id | RESOURCE_ID_MASK;
>      goodid = 0;
> -    for (resp = clientTable[client].resources, i = clientTable[client].buckets;
> -	 --i >= 0;)
> +    resp = clientTable[client].resources;
> +    if (clientTable[client].buckets)
>      {
>  	for (res = *resp++; res; res = res->next)
>  	{

Couldn't this all be better written as:
    for (i = 0; i < clientTable[client].buckets; i++)
    {
        res = clientTable[client].resources[i];
        [...]
    }

Cheers,
Daniel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.x.org/archives/xorg-devel/attachments/20110110/a3fe2c0d/attachment.pgp>


More information about the xorg-devel mailing list