Skip to contentSkip to conversation

show-branch: Fix another performance problem.

PATCH In review Alexandre Julliard 2 participants 2 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 show-branch: Fix another performance problem.

When naming commits, stop walking the parent chain as soon as we find a commit that already has a name. The parent chain of that commit will be walked later on in any case (or may even have been walked already). This avoids O(n^2) behavior; on a tree where show-branch displays 6800 commits, the total run time drops from 77 seconds to 5 seconds.

---
 builtin-show-branch.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
builtin-show-branch.c +2 -0
index 3d240ca..82f75b7 100644
@@ -89,6 +89,8 @@ static int name_first_parent_chain(struc
 			name_parent(c, p);
 			i++;
 		}
+		else
+			break;
 		c = p;
 	}
 	return i;
Signature · 5 lines
1.4.2.rc1.ge7a0

-- 
Alexandre Julliard
[email protected]