Show More
@@ -1,7 +1,7 b'' | |||||
1 | use bytes_cast::BytesCast; |
|
1 | use bytes_cast::BytesCast; | |
2 | use micro_timer::timed; |
|
2 | use micro_timer::timed; | |
|
3 | use std::convert::TryInto; | |||
3 | use std::path::PathBuf; |
|
4 | use std::path::PathBuf; | |
4 | use std::{collections::BTreeMap, convert::TryInto}; |
|
|||
5 |
|
5 | |||
6 | use super::path_with_basename::WithBasename; |
|
6 | use super::path_with_basename::WithBasename; | |
7 | use crate::dirstate::parsers::clear_ambiguous_mtime; |
|
7 | use crate::dirstate::parsers::clear_ambiguous_mtime; | |
@@ -20,6 +20,7 b' use crate::DirstateMapError;' | |||||
20 | use crate::DirstateParents; |
|
20 | use crate::DirstateParents; | |
21 | use crate::DirstateStatus; |
|
21 | use crate::DirstateStatus; | |
22 | use crate::EntryState; |
|
22 | use crate::EntryState; | |
|
23 | use crate::FastHashMap; | |||
23 | use crate::PatternFileWarning; |
|
24 | use crate::PatternFileWarning; | |
24 | use crate::StateMapIter; |
|
25 | use crate::StateMapIter; | |
25 | use crate::StatusError; |
|
26 | use crate::StatusError; | |
@@ -43,7 +44,7 b' pub struct DirstateMap {' | |||||
43 | /// path, so comparing full paths gives the same result as comparing base |
|
44 | /// path, so comparing full paths gives the same result as comparing base | |
44 | /// names. However `BTreeMap` would waste time always re-comparing the same |
|
45 | /// names. However `BTreeMap` would waste time always re-comparing the same | |
45 | /// string prefix. |
|
46 | /// string prefix. | |
46 |
pub(super) type ChildNodes = |
|
47 | pub(super) type ChildNodes = FastHashMap<WithBasename<HgPathBuf>, Node>; | |
47 |
|
48 | |||
48 | /// Represents a file or a directory |
|
49 | /// Represents a file or a directory | |
49 | #[derive(Default)] |
|
50 | #[derive(Default)] | |
@@ -86,7 +87,7 b' impl DirstateMap {' | |||||
86 | Self { |
|
87 | Self { | |
87 | parents: None, |
|
88 | parents: None, | |
88 | dirty_parents: false, |
|
89 | dirty_parents: false, | |
89 |
root: ChildNodes:: |
|
90 | root: ChildNodes::default(), | |
90 | nodes_with_entry_count: 0, |
|
91 | nodes_with_entry_count: 0, | |
91 | nodes_with_copy_source_count: 0, |
|
92 | nodes_with_copy_source_count: 0, | |
92 | } |
|
93 | } |
@@ -55,6 +55,12 b' impl<T: AsRef<HgPath>> Borrow<HgPath> fo' | |||||
55 | } |
|
55 | } | |
56 | } |
|
56 | } | |
57 |
|
57 | |||
|
58 | impl<T: AsRef<HgPath>> std::hash::Hash for WithBasename<T> { | |||
|
59 | fn hash<H: std::hash::Hasher>(&self, hasher: &mut H) { | |||
|
60 | self.base_name().hash(hasher) | |||
|
61 | } | |||
|
62 | } | |||
|
63 | ||||
58 | impl<T: AsRef<HgPath> + PartialEq> PartialEq for WithBasename<T> { |
|
64 | impl<T: AsRef<HgPath> + PartialEq> PartialEq for WithBasename<T> { | |
59 | fn eq(&self, other: &Self) -> bool { |
|
65 | fn eq(&self, other: &Self) -> bool { | |
60 | self.base_name() == other.base_name() |
|
66 | self.base_name() == other.base_name() |
@@ -110,11 +110,11 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 | // |
|
113 | let mut dirstate_nodes: Vec<_> = dirstate_nodes.iter_mut().collect(); | |
114 | // * `BTreeMap` iterates according to keys’ ordering by definition |
|
|||
115 |
|
||||
116 | // `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: | |
117 | // 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)); |
|
118 | fs_entries.sort_unstable_by(|e1, e2| e1.base_name.cmp(&e2.base_name)); | |
119 |
|
119 | |||
120 | itertools::merge_join_by( |
|
120 | itertools::merge_join_by( |
General Comments 0
You need to be logged in to leave comments.
Login now