[PATCH] dix: improve control flow in QueryTrackers

Peter Hutterer peter.hutterer at who-t.net
Wed Apr 20 22:04:46 PDT 2011


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 <peter.hutterer at who-t.net>
---
This incorporates the control flow change that sneaked into 11/20 and
Jamey's suggestion for the DebugAccelF move.

 dix/ptrveloc.c |   23 +++++++++++++----------
 1 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/dix/ptrveloc.c b/dix/ptrveloc.c
index f4548b6..758e204 100644
--- a/dix/ptrveloc.c
+++ b/dix/ptrveloc.c
@@ -628,26 +628,29 @@ QueryTrackers(DeviceVelocityPtr vel, int cur_t){
 
 	tracker_velocity = CalcTracker(tracker, cur_t) * velocity_factor;
 
-	if ((initial_velocity == 0 || offset <= vel->initial_range) && tracker_velocity != 0) {
+	if (tracker_velocity == 0)
+	    continue;
+
+	if (initial_velocity == 0 || offset <= vel->initial_range) {
 	    /* set initial velocity and result */
 	    result = initial_velocity = tracker_velocity;
 	    used_offset = offset;
-	} else if (initial_velocity != 0 && tracker_velocity != 0) {
+	} else if (initial_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){
-- 
1.7.4.4



More information about the xorg-devel mailing list