From ae32e0a17beafc7132eeb9b3c3ecb5298cfb4cfc Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Mon, 20 Jul 2015 11:09:19 +1000 Subject: [PATCH] Drop vector_length(), replace with hypot(3) Signed-off-by: Peter Hutterer --- src/evdev-mt-touchpad.c | 2 +- src/libinput-util.h | 6 ------ test/pointer.c | 2 +- 3 files changed, 2 insertions(+), 8 deletions(-) diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c index b06449bd..b73138c8 100644 --- a/src/evdev-mt-touchpad.c +++ b/src/evdev-mt-touchpad.c @@ -439,7 +439,7 @@ tp_unpin_finger(struct tp_dispatch *tp, struct tp_touch *t) ydist *= tp->buttons.motion_dist.y_scale_coeff; /* 3mm movement -> unpin */ - if (vector_length(xdist, ydist) >= 3.0) { + if (hypot(xdist, ydist) >= 3.0) { t->pinned.is_pinned = false; return; } diff --git a/src/libinput-util.h b/src/libinput-util.h index f27bcfd4..b18aece5 100644 --- a/src/libinput-util.h +++ b/src/libinput-util.h @@ -299,10 +299,4 @@ int parse_mouse_wheel_click_angle_property(const char *prop); double parse_trackpoint_accel_property(const char *prop); bool parse_dimension_property(const char *prop, size_t *width, size_t *height); -static inline double -vector_length(double x, double y) -{ - return sqrt(x * x + y * y); -} - #endif /* LIBINPUT_UTIL_H */ diff --git a/test/pointer.c b/test/pointer.c index 28d7c9a6..c781505f 100644 --- a/test/pointer.c +++ b/test/pointer.c @@ -197,7 +197,7 @@ START_TEST(pointer_motion_relative_min_decel) ck_assert((evx == 0.0) == (dx == 0)); ck_assert((evy == 0.0) == (dy == 0)); - len = vector_length(evx, evy); + len = hypot(evx, evy); ck_assert(fabs(len) >= 0.3); libinput_event_destroy(event);