From 67ca161f2487bf7d3453fdf2d125843789472bfd Mon Sep 17 00:00:00 2001 From: Martin von Zweigbergk Date: Sat, 24 Apr 2021 10:54:39 -0700 Subject: [PATCH] cli: key nodes in graphlog by position in index instead of by commit id This speeds up `jj log -T "" -r ,,v2.0.0` in the git.git repo by about 1.6 dB (~31%). --- src/commands.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/commands.rs b/src/commands.rs index 63ce336f9..92a6d7344 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -1062,23 +1062,23 @@ fn cmd_log( if use_graph { let mut graph = AsciiGraphDrawer::new(&mut styler); for index_entry in revset.iter() { - let commit = store.get_commit(&index_entry.commit_id()).unwrap(); let mut edges = vec![]; - for parent in commit.parents() { + for parent_position in index_entry.parent_positions() { // TODO: Use the right kind of edge here. - edges.push(Edge::direct(parent.id().clone())); + edges.push(Edge::direct(parent_position)); } let mut buffer = vec![]; // TODO: only use color if requested { let writer = Box::new(&mut buffer); let mut styler = ColorStyler::new(writer, ui.settings()); + let commit = store.get_commit(&index_entry.commit_id()).unwrap(); template.format(&commit, &mut styler)?; } if !buffer.ends_with(b"\n") { buffer.push(b'\n'); } - graph.add_node(commit.id(), &edges, b"o", &buffer)?; + graph.add_node(&index_entry.position(), &edges, b"o", &buffer)?; } } else { for index_entry in revset.iter() {