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