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