diff options
author | Wilfred Hughes <me@wilfred.me.uk> | 2022-04-26 00:01:33 -0700 |
---|---|---|
committer | Wilfred Hughes <me@wilfred.me.uk> | 2022-04-29 16:44:51 -0700 |
commit | 735d7a330216cc376476940d74765644aabb626e (patch) | |
tree | d191ee518dd0cb18db2473cc5bae15d702c07afb | |
parent | 7d5616d0af8ad2da8a0aac91074486fdf50f5e87 (diff) |
WIP parallel iter on sections for accumlating change mapspass_end_node
-rw-r--r-- | src/changes.rs | 4 | ||||
-rw-r--r-- | src/main.rs | 36 |
2 files changed, 27 insertions, 13 deletions
diff --git a/src/changes.rs b/src/changes.rs index 1176971d5c..b49807616b 100644 --- a/src/changes.rs +++ b/src/changes.rs @@ -32,6 +32,10 @@ impl<'a> ChangeMap<'a> { pub fn get(&self, node: &Syntax<'a>) -> Option<ChangeKind<'a>> { self.changes.get(&node.id()).copied() } + + pub fn extend(&mut self, other: Self) { + self.changes.extend(other.changes); + } } pub fn insert_deep_unchanged<'a>( diff --git a/src/main.rs b/src/main.rs index 549105543a..c036230d02 100644 --- a/src/main.rs +++ b/src/main.rs @@ -308,20 +308,30 @@ fn diff_file_content( rhs_positions, ) } else { - for (lhs_section_nodes, rhs_section_nodes) in possibly_changed { - mark_syntax( - lhs_section_nodes.first().copied(), - rhs_section_nodes.first().copied(), - lhs_section_nodes.last().and_then(|n| n.next_sibling()), - rhs_section_nodes.last().and_then(|n| n.next_sibling()), - &mut change_map, - ); - - let language = language.unwrap(); - fix_all_sliders(language, &lhs_section_nodes, &mut change_map); - fix_all_sliders(language, &rhs_section_nodes, &mut change_map); + let change_maps: Vec<_> = possibly_changed + .par_iter() + .map(|(lhs_section_nodes, rhs_section_nodes)| { + let mut change_map = ChangeMap::default(); + mark_syntax( + lhs_section_nodes.first().copied(), + rhs_section_nodes.first().copied(), + lhs_section_nodes.last().and_then(|n| n.next_sibling()), + rhs_section_nodes.last().and_then(|n| n.next_sibling()), + &mut change_map, + ); + + let language = language.unwrap(); + fix_all_sliders(language, lhs_section_nodes, &mut change_map); + fix_all_sliders(language, rhs_section_nodes, &mut change_map); + + change_map + }) + .collect(); + + for section_change_map in change_maps { + change_map.extend(section_change_map); } - + let lhs_positions = syntax::change_positions(&lhs, &change_map); let rhs_positions = syntax::change_positions(&rhs, &change_map); (Some(ts_lang.name.into()), lhs_positions, rhs_positions) |