From: Hans de Goede Date: Mon, 30 Jun 2014 12:27:18 +0000 (+0200) Subject: touchpad: Simplify tp_hysteresis X-Git-Tag: 0.5.0~61 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=14ad471ff5797ca5a77a377aeaad07833af63144;p=platform%2Fupstream%2Flibinput.git touchpad: Simplify tp_hysteresis 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 Reviewed-by: Peter Hutterer Signed-off-by: Peter Hutterer --- diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c index ced92378..9e858f13 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