[Change] Switched l+(h-l)/2 to (h+l) >> 1 in binary search.

This commit is contained in:
Allanis 2013-07-04 13:43:24 +01:00
parent 19e3e818a4
commit 8213cb9f48

View File

@ -68,7 +68,7 @@ unsigned int pilot_getNext(const unsigned int id) {
l = 0; l = 0;
h = pilot_nstack-1; h = pilot_nstack-1;
while(l <= h) { while(l <= h) {
m = l+(h-l)/2; /* For impossible overflow returning negative value. */ m = (l+h) >> 1; /* For impossible overflow returning negative value. */
if(pilot_stack[m]->id > id) h = m-1; if(pilot_stack[m]->id > id) h = m-1;
else if(pilot_stack[m]->id < id) l = m+1; else if(pilot_stack[m]->id < id) l = m+1;
else break; else break;