ok/jj
1
0
Fork 0
forked from mirrors/jj

style: simplify topo_order()

- Calling `.into_iter()` on an iterator is a no-op.
- There is no need to wrap index entries into another type to unwrap
  them right after sorting.
This commit is contained in:
Samuel Tardieu 2023-02-20 09:23:00 +01:00
parent c2df989fe9
commit e9009cf21e

View file

@ -923,15 +923,9 @@ impl<'a> CompositeIndex<'a> {
/// Parents before children
pub fn topo_order(&self, input: &mut dyn Iterator<Item = &CommitId>) -> Vec<IndexEntry<'a>> {
let mut entries_by_generation = input
.into_iter()
.map(|id| IndexEntryByPosition(self.entry_by_id(id).unwrap()))
.collect_vec();
entries_by_generation.sort();
let mut entries_by_generation = input.map(|id| self.entry_by_id(id).unwrap()).collect_vec();
entries_by_generation.sort_unstable_by_key(|e| e.pos);
entries_by_generation
.into_iter()
.map(|key| key.0)
.collect_vec()
}
}