mirror of
https://github.com/martinvonz/jj.git
synced 2025-01-18 02:04:19 +00:00
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:
parent
c2df989fe9
commit
e9009cf21e
1 changed files with 2 additions and 8 deletions
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue