comparison rust/hg-core/src/dirstate_tree/dirstate_map.rs @ 47331:0252600fd1cf

dirstate-tree: Downgrade `&mut Node` to `&Node` in status and serialization Mutable access is not used, and upcoming changes will make it more costly (with copy-on-write nodes that can be read from disk representation) Differential Revision: https://phab.mercurial-scm.org/D10745
author Simon Sapin <simon.sapin@octobus.net>
date Wed, 19 May 2021 13:15:00 +0200
parents 73f23e7610f8
children 4ee9f419c52e
comparison
equal deleted inserted replaced
47330:73f23e7610f8 47331:0252600fd1cf
66 pub(super) fn state(&self) -> Option<EntryState> { 66 pub(super) fn state(&self) -> Option<EntryState> {
67 self.entry.as_ref().map(|entry| entry.state) 67 self.entry.as_ref().map(|entry| entry.state)
68 } 68 }
69 69
70 pub(super) fn sorted<'tree>( 70 pub(super) fn sorted<'tree>(
71 nodes: &'tree mut ChildNodes<'on_disk>, 71 nodes: &'tree ChildNodes<'on_disk>,
72 ) -> Vec<(&'tree NodeKey<'on_disk>, &'tree mut Self)> { 72 ) -> Vec<(&'tree NodeKey<'on_disk>, &'tree Self)> {
73 let mut vec: Vec<_> = nodes.iter_mut().collect(); 73 let mut vec: Vec<_> = nodes.iter().collect();
74 // `sort_unstable_by_key` doesn’t allow keys borrowing from the value: 74 // `sort_unstable_by_key` doesn’t allow keys borrowing from the value:
75 // https://github.com/rust-lang/rust/issues/34162 75 // https://github.com/rust-lang/rust/issues/34162
76 vec.sort_unstable_by(|(path1, _), (path2, _)| path1.cmp(path2)); 76 vec.sort_unstable_by(|(path1, _), (path2, _)| path1.cmp(path2));
77 vec 77 vec
78 } 78 }