[PATCH 16/16] bisect: get back halfway shortcut

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

 



The documentation says that when the maximum possible distance
is found, the algorithm stops immediately. That feature is
reestablished by this commit.

Signed-off-by: Stephan Beyer <s-beyer@xxxxxxx>
---

In my tests, I have not seen any gain of performance by
doing this... but it's fast now anyway, who cares ;-)

 bisect.c | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/bisect.c b/bisect.c
index 185a3cf..0153d9a 100644
--- a/bisect.c
+++ b/bisect.c
@@ -363,8 +363,8 @@ static void commit_list_insert_unique(struct commit *item,
 }
 
 /* do a BFS on the reversed DAG (starting from commits in queue), stop at merge commits */
-static void bfs_up_to_merges(struct commit_list *queue,
-			     struct commit_list **merges)
+static int bfs_up_to_merges(struct commit_list *queue,
+			    struct commit_list **merges)
 {
 	assert(queue);
 	struct commit_list **last;
@@ -391,8 +391,13 @@ static void bfs_up_to_merges(struct commit_list *queue,
 		}
 
 		update_best_bisection(top);
+		if (distance_direction(top) == 0) { // halfway
+			assert(!(top->object.flags & TREESAME));
+			return 1;
+		}
 		pop_commit(&queue);
 	}
+	return 0;
 }
 
 static int all_parents_are_visited(struct commit *merge)
@@ -456,10 +461,12 @@ static void compute_merge_weights(struct commit_list *merges)
 static void modified_bfs(struct commit_list *queue)
 {
 	struct commit_list *merges = NULL;
-	bfs_up_to_merges(queue, &merges);
-	while (find_new_queue_from_merges(&queue, &merges)) {
+	int halfway_found = bfs_up_to_merges(queue, &merges);
+
+	while (!halfway_found
+	    && find_new_queue_from_merges(&queue, &merges)) {
 		compute_merge_weights(queue);
-		bfs_up_to_merges(queue, &merges);
+		halfway_found &= bfs_up_to_merges(queue, &merges);
 	}
 }
 
-- 
2.7.1.354.gd492730.dirty

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]