fn highlight_positions(
    background: BackgroundColor,
    lhs_mps: &[MatchedPos],
    rhs_mps: &[MatchedPos],
) -> (
    HashMap<LineNumber, Vec<(SingleLineSpan, Style)>>,
    HashMap<LineNumber, Vec<(SingleLineSpan, Style)>>,
) {
    let lhs_positions = color_positions(true, background, 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);
    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, rhs_mps);
    let mut rhs_styles: HashMap<LineNumber, Vec<(SingleLineSpan, Style)>> =
        HashMap::with_capacity(rhs_positions.len() / 2);
    for (span, style) in rhs_positions {
        let styles = rhs_styles.entry(span.line).or_insert_with(Vec::new);
        styles.push((span, style));
    }

    (lhs_styles, rhs_styles)
}
/// Calculate positions of highlights on both sides. This includes
/// both syntax highlighting and added/removed content highlighting.
Calculate positions of highlights on both sides. This includes
both syntax highlighting and added/removed content highlighting.
Calculate positions of highlights on both sides . This includes both syntax highlighting and added / removed content highlighting .
fn highlight_positions(
    background: BackgroundColor,
    lhs_mps: &[MatchedPos],
    rhs_mps: &[MatchedPos],
) -> (
    HashMap<LineNumber, Vec<(SingleLineSpan, Style)>>,
    HashMap<LineNumber, Vec<(SingleLineSpan, Style)>>,
) {
    let lhs_positions = color_positions(true, background, 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);
    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, rhs_mps);
    let mut rhs_styles: HashMap<LineNumber, Vec<(SingleLineSpan, Style)>> =
        HashMap::with_capacity(rhs_positions.len() / 2);
    for (span, style) in rhs_positions {
        let styles = rhs_styles.entry(span.line).or_insert_with(Vec::new);
        styles.push((span, style));
    }
    (lhs_styles, rhs_styles)
}
fn highlight_positions ( background : BackgroundColor , lhs_mps : & [ MatchedPos ] , rhs_mps : & [ MatchedPos ] , ) -> ( HashMap < LineNumber , Vec < ( SingleLineSpan , Style ) > > , HashMap < LineNumber , Vec < ( SingleLineSpan , Style ) > > , ) { let lhs_positions = color_positions ( true , background , 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 ) ; 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 , rhs_mps ) ; let mut rhs_styles : HashMap < LineNumber , Vec < ( SingleLineSpan , Style ) > > = HashMap :: with_capacity ( rhs_positions . len ( ) / 2 ) ; for ( span , style ) in rhs_positions { let styles = rhs_styles . entry ( span . line ) . or_insert_with ( Vec :: new ) ; styles . push ( ( span , style ) ) ; } ( lhs_styles , rhs_styles ) }
Calculate positions of highlights on both sides.
Calculate positions of highlights on both sides .
background
BackgroundColor
lhs_mps
&[MatchedPos]
rhs_mps
&[MatchedPos]