[PATCH] mi: streamline CopyGetMasterEvent(), remove code duplication.

Daniel Stone daniel at fooishbar.org
Tue Dec 9 17:01:54 PST 2008


On Wed, Dec 10, 2008 at 09:18:12AM +1000, Peter Hutterer wrote:
> How about this one?

Looks nicer, acked conditional on one nitpick.

> From 9be3abf13d291879e37652f7364c2712f6bcc592 Mon Sep 17 00:00:00 2001
> From: Peter Hutterer <peter.hutterer at redhat.com>
> Date: Mon, 1 Dec 2008 21:20:48 +1000
> Subject: [PATCH] mi: Clean up CopyGetMasterEvent, re-use the memory.
> 
> Alloc an EventList once and then re-use instead of allocing a new event each
> time we need a master event.
> There's a trick included: because all the event processing handlers only take
> an xEvent, init a size 1 EventList and squash the events into this one.
> 
> Events that have count > 1 must be squished into an xEvent array anyway before
> passing into the event handlers, so we don't lose anything here.
> 
> Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

Acked-by: Daniel Stone <daniel at fooishbar.org>

> @@ -98,6 +99,17 @@ mieqInit(void)
>              FatalError("Could not allocate event queue.\n");
>          miEventQueue.events[i].events = evlist;
>      }
> +
> +    /* XXX: mE is just 1 event long, if we have Motion + Valuator they are
> +     * squashed into the first event to make passing it into the event
> +     * processing handlers easier. This should be fixed when the processing
> +     * handlers switch to EventListPtr instead of xEvent */
> +    masterEvents = InitEventList(1);
> +    if (!masterEvents)
> +        FatalError("Could not allocated MD event queue.\n");
> +    SetMinimumEventSize(masterEvents, 1,
> +                        7 /* 1 + MAX_VALUATOR_EVENTS */  * sizeof(xEvent));
> +
>      SetInputCheck(&miEventQueue.head, &miEventQueue.tail);
>      return TRUE;
>  }

Do you want to make that actually 1 + M_V_E instead of a hardcoded value
and then having the calculation in a comment right there anyway?

Cheers,
Daniel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 197 bytes
Desc: Digital signature
URL: <http://lists.x.org/archives/xorg/attachments/20081210/f06f5e4d/attachment.pgp>


More information about the xorg mailing list