[PATCH libinput 1/2] touchpad: Simplify tp_hysteresis

Peter Hutterer peter.hutterer at who-t.net
Mon Jun 30 18:08:15 PDT 2014


On Mon, Jun 30, 2014 at 02:27:18PM +0200, Hans de Goede wrote:
> Once we get beyond the:
> 
> 	if (abs(diff) <= margin)
> 		return center;
> 
> test, then diff is either > margin or < -margin, otherwise the test would
> have triggered.
> 
> So the "return center + diff;" at the end will never be reached, and the
> "else if (diff < -margin)" can be turned into a simple "else".
> 
> This commit does not just simplify tp_hysteresis, but (arguably more
> important) also makes it clearer to the reader what it does.
> 
> Signed-off-by: Hans de Goede <hdegoede at redhat.com>

pushed, thanks

Cheers,
   Peter

> ---
>  src/evdev-mt-touchpad.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c
> index ced9237..9e858f1 100644
> --- a/src/evdev-mt-touchpad.c
> +++ b/src/evdev-mt-touchpad.c
> @@ -42,9 +42,8 @@ tp_hysteresis(int in, int center, int margin)
>  
>  	if (diff > margin)
>  		return center + diff - margin;
> -	else if (diff < -margin)
> +	else
>  		return center + diff + margin;
> -	return center + diff;
>  }
>  
>  static double
> -- 
> 2.0.0
> 


More information about the wayland-devel mailing list