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 <peter.hutterer@who-t.net>
Reviewed-by: Jamey Sharp <jamey@minilop.net>
This commit is contained in:
Peter Hutterer 2011-04-21 14:55:22 +10:00
parent a0eda8cd36
commit 6f97fe5df1

View File

@ -634,20 +634,20 @@ QueryTrackers(DeviceVelocityPtr vel, int cur_t){
used_offset = offset; used_offset = offset;
} else if (initial_velocity != 0 && tracker_velocity != 0) { } else if (initial_velocity != 0 && tracker_velocity != 0) {
velocity_diff = fabs(initial_velocity - tracker_velocity); velocity_diff = fabs(initial_velocity - tracker_velocity);
if (velocity_diff <= vel->max_diff ||
velocity_diff/(initial_velocity + tracker_velocity) < vel->max_rel_diff) { if (velocity_diff > vel->max_diff &&
/* we're in range with the initial velocity, velocity_diff/(initial_velocity + tracker_velocity) >= vel->max_rel_diff) {
* so this result is likely better
* (it contains more information). */
result = tracker_velocity;
used_offset = offset;
}else{
/* we're not in range, quit - it won't get better. */ /* we're not in range, quit - it won't get better. */
DebugAccelF("(dix prtacc) query: tracker too different:" DebugAccelF("(dix prtacc) query: tracker too different:"
" old %2.2f initial %2.2f diff: %2.2f\n", " old %2.2f initial %2.2f diff: %2.2f\n",
tracker_velocity, initial_velocity, velocity_diff); tracker_velocity, initial_velocity, velocity_diff);
break; 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){ if(offset == vel->num_tracker){