mirror of
https://github.com/martinvonz/jj.git
synced 2025-01-18 10:07:28 +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
|
/// 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()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue