On Fri, Sep 30, 2011 at 11:55:35PM +0100, Daniel Stone wrote:
> Hi,
>
> On 30 September 2011 17:18, Chase Douglas <[email protected]> wrote:
> > On 09/29/2011 09:29 PM, Peter Hutterer wrote:
> >> Using this call simplifies callers that don't know if the mask bit is set.
> >>
> >> Before:
> >> if (valuator_mask_isset(mask, valnum))
> >> value = valuator_mask_get_double(mask, valnum));
> >> else
> >> value = someothervalue;
> >>
> >> Now:
> >> if (!valuator_mask_fetch_double(mask, valnum, &value))
> >> value = someothervalue;
> >>
> >> Signed-off-by: Peter Hutterer <[email protected]>
> >
> > I think this will help clean up code all over :).
> >
> > Reviewed-by: Chase Douglas <[email protected]>
>
> Yeah, seriously. Is there any good reason to not make a double which
> returns either 0.0 (if not set) or the mask value (if set) though, on
> the grounds that anyone who wants to know will be using
> isset/get_double?
If I understand this right - I specifically chose not to do this, it allows
for setting value to some (alternative) value and then simply calling fetch,
knowing that the value after fetch will be correct.
in the simplest case:
int val = dev->last.valuator[0];
valuator_mask_fetch(mask, 0, &val);
It's not a big difference, I admit, but since 0 can be a valid valuator
value, simply not touching the parameter when we don't know what to set it
to seems the best.
Cheers,
Peter
_______________________________________________
[email protected]: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel