From 6bc1361b848d45dc9fc54fb06678ffe8e6a7edc2 Mon Sep 17 00:00:00 2001 From: Martin von Zweigbergk Date: Wed, 21 Apr 2021 16:26:17 -0700 Subject: [PATCH] index: make revision walk be by position instead of generation number I don't know why I made it walk by generation number to start with. Walking by position is better in at least two ways: 1) revsets now depend on the walks to be by descending index position (though they could equally well depend on the walks to be by generation number -- it just needs to be consistent), and 2) the log output gets less interleaved. This commit makes the number of bytes in the graphlog output in the git.git repo drop by ~40% due to the reduced amount of interleaving. Also, it reduces the time of `jj bench walkrevs v1.0.0 v2.0.0` in the git.git repo by 32% (9.4ms -> 6.4ms) and `jj bench walkrevs v2.0.0 v1.0.0` by 33% (7.7ms -> 5.1ms). --- lib/src/index.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/src/index.rs b/lib/src/index.rs index baf909c86..0ef1e338a 100644 --- a/lib/src/index.rs +++ b/lib/src/index.rs @@ -1009,7 +1009,7 @@ impl PartialOrd for IndexEntryByGeneration<'_> { #[derive(Clone, Eq, PartialEq, Ord, PartialOrd)] struct RevWalkWorkItem<'a> { - entry: IndexEntryByGeneration<'a>, + entry: IndexEntryByPosition<'a>, wanted: bool, } @@ -1036,7 +1036,7 @@ impl<'a> RevWalk<'a> { return; } self.items.push(RevWalkWorkItem { - entry: IndexEntryByGeneration(self.index.entry_by_pos(pos)), + entry: IndexEntryByPosition(self.index.entry_by_pos(pos)), wanted: true, }); } @@ -1046,7 +1046,7 @@ impl<'a> RevWalk<'a> { return; } self.items.push(RevWalkWorkItem { - entry: IndexEntryByGeneration(self.index.entry_by_pos(pos)), + entry: IndexEntryByPosition(self.index.entry_by_pos(pos)), wanted: false, }); }