|
|
|
|
@ -1,10 +1,8 @@
|
|
|
|
|
//! Side-by-side (two column) display of diffs.
|
|
|
|
|
|
|
|
|
|
use owo_colors::{OwoColorize, Style};
|
|
|
|
|
use std::{
|
|
|
|
|
cmp::max,
|
|
|
|
|
collections::{HashMap, HashSet},
|
|
|
|
|
};
|
|
|
|
|
use rustc_hash::FxHashMap;
|
|
|
|
|
use std::{cmp::max, collections::HashSet};
|
|
|
|
|
|
|
|
|
|
use crate::{
|
|
|
|
|
constants::Side,
|
|
|
|
|
@ -250,21 +248,19 @@ fn highlight_positions(
|
|
|
|
|
lhs_mps: &[MatchedPos],
|
|
|
|
|
rhs_mps: &[MatchedPos],
|
|
|
|
|
) -> (
|
|
|
|
|
HashMap<LineNumber, Vec<(SingleLineSpan, Style)>>,
|
|
|
|
|
HashMap<LineNumber, Vec<(SingleLineSpan, Style)>>,
|
|
|
|
|
FxHashMap<LineNumber, Vec<(SingleLineSpan, Style)>>,
|
|
|
|
|
FxHashMap<LineNumber, Vec<(SingleLineSpan, Style)>>,
|
|
|
|
|
) {
|
|
|
|
|
let lhs_positions = color_positions(true, background, syntax_highlight, lhs_mps);
|
|
|
|
|
// Preallocate the hashmap assuming the average line will have 2 items on it.
|
|
|
|
|
let mut lhs_styles: HashMap<LineNumber, Vec<(SingleLineSpan, Style)>> =
|
|
|
|
|
HashMap::with_capacity(lhs_positions.len() / 2);
|
|
|
|
|
let mut lhs_styles: FxHashMap<LineNumber, Vec<(SingleLineSpan, Style)>> = FxHashMap::default();
|
|
|
|
|
for (span, style) in lhs_positions {
|
|
|
|
|
let styles = lhs_styles.entry(span.line).or_insert_with(Vec::new);
|
|
|
|
|
styles.push((span, style));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let rhs_positions = color_positions(false, background, syntax_highlight, rhs_mps);
|
|
|
|
|
let mut rhs_styles: HashMap<LineNumber, Vec<(SingleLineSpan, Style)>> =
|
|
|
|
|
HashMap::with_capacity(rhs_positions.len() / 2);
|
|
|
|
|
let mut rhs_styles: FxHashMap<LineNumber, Vec<(SingleLineSpan, Style)>> = FxHashMap::default();
|
|
|
|
|
for (span, style) in rhs_positions {
|
|
|
|
|
let styles = rhs_styles.entry(span.line).or_insert_with(Vec::new);
|
|
|
|
|
styles.push((span, style));
|
|
|
|
|
@ -367,7 +363,7 @@ pub fn print(
|
|
|
|
|
rhs_mps,
|
|
|
|
|
)
|
|
|
|
|
} else {
|
|
|
|
|
(HashMap::new(), HashMap::new())
|
|
|
|
|
(FxHashMap::default(), FxHashMap::default())
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
let lhs_lines = split_on_newlines(lhs_src);
|
|
|
|
|
|