From 6f97fe5df16f947e52875187ff4f9e25fab33ad7 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Thu, 21 Apr 2011 14:55:22 +1000 Subject: [PATCH] dix: improve control flow in QueryTrackers If the velocity is 0, skip the remainder. If we're not in range, skip the remainder. No functional change. Signed-off-by: Peter Hutterer Reviewed-by: Jamey Sharp --- dix/ptrveloc.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/dix/ptrveloc.c b/dix/ptrveloc.c index f4548b6e9..dfccf1581 100644 --- a/dix/ptrveloc.c +++ b/dix/ptrveloc.c @@ -634,20 +634,20 @@ QueryTrackers(DeviceVelocityPtr vel, int cur_t){ used_offset = offset; } else if (initial_velocity != 0 && tracker_velocity != 0) { velocity_diff = fabs(initial_velocity - tracker_velocity); - if (velocity_diff <= vel->max_diff || - velocity_diff/(initial_velocity + tracker_velocity) < vel->max_rel_diff) { - /* we're in range with the initial velocity, - * so this result is likely better - * (it contains more information). */ - result = tracker_velocity; - used_offset = offset; - }else{ + + if (velocity_diff > vel->max_diff && + velocity_diff/(initial_velocity + tracker_velocity) >= vel->max_rel_diff) { /* we're not in range, quit - it won't get better. */ DebugAccelF("(dix prtacc) query: tracker too different:" " old %2.2f initial %2.2f diff: %2.2f\n", tracker_velocity, initial_velocity, velocity_diff); break; } + /* we're in range with the initial velocity, + * so this result is likely better + * (it contains more information). */ + result = tracker_velocity; + used_offset = offset; } } if(offset == vel->num_tracker){