Show More
@@ -45,10 +45,11 b" pub struct DirstateMap<'on_disk> {" | |||||
45 | /// Using a plain `HgPathBuf` of the full path from the repository root as a |
|
45 | /// Using a plain `HgPathBuf` of the full path from the repository root as a | |
46 | /// map key would also work: all paths in a given map have the same parent |
|
46 | /// map key would also work: all paths in a given map have the same parent | |
47 | /// path, so comparing full paths gives the same result as comparing base |
|
47 | /// path, so comparing full paths gives the same result as comparing base | |
48 |
/// names. However ` |
|
48 | /// names. However `HashMap` would waste time always re-hashing the same | |
49 | /// string prefix. |
|
49 | /// string prefix. | |
|
50 | pub(super) type NodeKey<'on_disk> = WithBasename<Cow<'on_disk, HgPath>>; | |||
50 | pub(super) type ChildNodes<'on_disk> = |
|
51 | pub(super) type ChildNodes<'on_disk> = | |
51 |
FastHashMap< |
|
52 | FastHashMap<NodeKey<'on_disk>, Node<'on_disk>>; | |
52 |
|
53 | |||
53 | /// Represents a file or a directory |
|
54 | /// Represents a file or a directory | |
54 | #[derive(Default)] |
|
55 | #[derive(Default)] | |
@@ -64,10 +65,20 b" pub(super) struct Node<'on_disk> {" | |||||
64 | tracked_descendants_count: usize, |
|
65 | tracked_descendants_count: usize, | |
65 | } |
|
66 | } | |
66 |
|
67 | |||
67 | impl Node<'_> { |
|
68 | impl<'on_disk> Node<'on_disk> { | |
68 | pub(super) fn state(&self) -> Option<EntryState> { |
|
69 | pub(super) fn state(&self) -> Option<EntryState> { | |
69 | self.entry.as_ref().map(|entry| entry.state) |
|
70 | self.entry.as_ref().map(|entry| entry.state) | |
70 | } |
|
71 | } | |
|
72 | ||||
|
73 | pub(super) fn sorted<'tree>( | |||
|
74 | nodes: &'tree mut ChildNodes<'on_disk>, | |||
|
75 | ) -> Vec<(&'tree NodeKey<'on_disk>, &'tree mut Self)> { | |||
|
76 | let mut vec: Vec<_> = nodes.iter_mut().collect(); | |||
|
77 | // `sort_unstable_by_key` doesn’t allow keys borrowing from the value: | |||
|
78 | // https://github.com/rust-lang/rust/issues/34162 | |||
|
79 | vec.sort_unstable_by(|(path1, _), (path2, _)| path1.cmp(path2)); | |||
|
80 | vec | |||
|
81 | } | |||
71 | } |
|
82 | } | |
72 |
|
83 | |||
73 | /// `(full_path, entry, copy_source)` |
|
84 | /// `(full_path, entry, copy_source)` |
@@ -110,11 +110,9 b" impl<'tree, 'a> StatusCommon<'tree, 'a> " | |||||
110 |
|
110 | |||
111 | // `merge_join_by` requires both its input iterators to be sorted: |
|
111 | // `merge_join_by` requires both its input iterators to be sorted: | |
112 |
|
112 | |||
113 |
let |
|
113 | let dirstate_nodes = Node::sorted(dirstate_nodes); | |
114 | // `sort_unstable_by_key` doesn’t allow keys borrowing from the value: |
|
114 | // `sort_unstable_by_key` doesn’t allow keys borrowing from the value: | |
115 | // https://github.com/rust-lang/rust/issues/34162 |
|
115 | // https://github.com/rust-lang/rust/issues/34162 | |
116 | dirstate_nodes |
|
|||
117 | .sort_unstable_by(|(path1, _), (path2, _)| path1.cmp(path2)); |
|
|||
118 | fs_entries.sort_unstable_by(|e1, e2| e1.base_name.cmp(&e2.base_name)); |
|
116 | fs_entries.sort_unstable_by(|e1, e2| e1.base_name.cmp(&e2.base_name)); | |
119 |
|
117 | |||
120 | itertools::merge_join_by( |
|
118 | itertools::merge_join_by( |
General Comments 0
You need to be logged in to leave comments.
Login now