[tracker/miner-priority-queues-0.10] libtracker-miner: Fix nasty typo in TrackerPriorityQueue



commit 63c3a8a2d9bf74eb2c7ec14caf2963720aea23fc
Author: Carlos Garnacho <carlos lanedo com>
Date:   Thu Jul 21 17:28:55 2011 +0200

    libtracker-miner: Fix nasty typo in TrackerPriorityQueue
    
    binary search wasn't working quite ok, even though it wasn't really
    noticeable in the most common case of having just 2 priorities in
    the segments array.

 src/libtracker-miner/tracker-priority-queue.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
---
diff --git a/src/libtracker-miner/tracker-priority-queue.c b/src/libtracker-miner/tracker-priority-queue.c
index a882c0a..d918f85 100644
--- a/src/libtracker-miner/tracker-priority-queue.c
+++ b/src/libtracker-miner/tracker-priority-queue.c
@@ -84,16 +84,16 @@ priority_segment_alloc_node (TrackerPriorityQueue *queue,
 	r = queue->segments->len - 1;
 
 	while (queue->segments->len > 0 && !found) {
-		c = r + l / 2;
+		c = (r + l) / 2;
 		segment = &g_array_index (queue->segments, PrioritySegment, c);
 
 		if (segment->priority == priority) {
 			found = TRUE;
 			break;
 		} else if (segment->priority > priority) {
-			l = c + 1;
-		} else if (segment->priority < priority) {
 			r = c - 1;
+		} else if (segment->priority < priority) {
+			l = c + 1;
 		}
 
 		if (l > r) {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]