##// END OF EJS Templates
rust-index: improve phase computation speed...
Raphaël Gomès -
r52318:7c6d0b9d default
parent child Browse files
Show More
@@ -1026,7 +1026,7 b' impl Index {'
1026 &self,
1026 &self,
1027 roots: HashMap<Phase, Vec<Revision>>,
1027 roots: HashMap<Phase, Vec<Revision>>,
1028 ) -> Result<(usize, RootsPerPhase), GraphError> {
1028 ) -> Result<(usize, RootsPerPhase), GraphError> {
1029 let mut phases = HashMap::new();
1029 let mut phases = vec![Phase::Public; self.len()];
1030 let mut min_phase_rev = NULL_REVISION;
1030 let mut min_phase_rev = NULL_REVISION;
1031
1031
1032 for phase in Phase::non_public_phases() {
1032 for phase in Phase::non_public_phases() {
@@ -1053,24 +1053,17 b' impl Index {'
1053 let rev = Revision(rev);
1053 let rev = Revision(rev);
1054 let [p1, p2] = self.parents(rev)?;
1054 let [p1, p2] = self.parents(rev)?;
1055
1055
1056 const DEFAULT_PHASE: &Phase = &Phase::Public;
1056 if p1.0 >= 0 && phases[p1.0 as usize] > phases[rev.0 as usize] {
1057 if p1.0 >= 0
1057 phases[rev.0 as usize] = phases[p1.0 as usize];
1058 && phases.get(&p1).unwrap_or(DEFAULT_PHASE)
1058 }
1059 > phases.get(&rev).unwrap_or(DEFAULT_PHASE)
1059 if p2.0 >= 0 && phases[p2.0 as usize] > phases[rev.0 as usize] {
1060 {
1060 phases[rev.0 as usize] = phases[p2.0 as usize];
1061 phases.insert(rev, phases[&p1]);
1062 }
1061 }
1063 if p2.0 >= 0
1062 let set = match phases[rev.0 as usize] {
1064 && phases.get(&p2).unwrap_or(DEFAULT_PHASE)
1065 > phases.get(&rev).unwrap_or(DEFAULT_PHASE)
1066 {
1067 phases.insert(rev, phases[&p2]);
1068 }
1069 let set = match phases.get(&rev).unwrap_or(DEFAULT_PHASE) {
1070 Phase::Public => continue,
1063 Phase::Public => continue,
1071 phase => &mut phase_sets[*phase as usize - 1],
1064 phase => &mut phase_sets[phase as usize - 1],
1072 };
1065 };
1073 set.insert(rev);
1066 set.push(rev);
1074 }
1067 }
1075
1068
1076 Ok((self.len(), phase_sets))
1069 Ok((self.len(), phase_sets))
@@ -1079,13 +1072,13 b' impl Index {'
1079 fn add_roots_get_min(
1072 fn add_roots_get_min(
1080 &self,
1073 &self,
1081 phase_roots: &[Revision],
1074 phase_roots: &[Revision],
1082 phases: &mut HashMap<Revision, Phase>,
1075 phases: &mut [Phase],
1083 phase: Phase,
1076 phase: Phase,
1084 ) -> Revision {
1077 ) -> Revision {
1085 let mut min_rev = NULL_REVISION;
1078 let mut min_rev = NULL_REVISION;
1086
1079
1087 for root in phase_roots {
1080 for root in phase_roots {
1088 phases.insert(*root, phase);
1081 phases[root.0 as usize] = phase;
1089 if min_rev == NULL_REVISION || min_rev > *root {
1082 if min_rev == NULL_REVISION || min_rev > *root {
1090 min_rev = *root;
1083 min_rev = *root;
1091 }
1084 }
@@ -1606,7 +1599,7 b' impl PoisonableBitSet for NonStaticPoiso'
1606 }
1599 }
1607
1600
1608 /// Set of roots of all non-public phases
1601 /// Set of roots of all non-public phases
1609 pub type RootsPerPhase = [HashSet<Revision>; Phase::non_public_phases().len()];
1602 pub type RootsPerPhase = [Vec<Revision>; Phase::non_public_phases().len()];
1610
1603
1611 #[derive(Debug, Copy, Clone, PartialEq, Eq, Ord, PartialOrd, Hash)]
1604 #[derive(Debug, Copy, Clone, PartialEq, Eq, Ord, PartialOrd, Hash)]
1612 pub enum Phase {
1605 pub enum Phase {
General Comments 0
You need to be logged in to leave comments. Login now