fn shrink_unchanged_at_ends<'a>(
    lhs_nodes: &[&'a Syntax<'a>],
    rhs_nodes: &[&'a Syntax<'a>],
) -> (bool, Vec<&'a Syntax<'a>>, Vec<&'a Syntax<'a>>) {
    let mut lhs_nodes = lhs_nodes;
    let mut rhs_nodes = rhs_nodes;

    let mut changed = false;
    while let (Some(lhs_node), Some(rhs_node)) = (lhs_nodes.first(), rhs_nodes.first()) {
        // We don't consider TINY_TREE_THRESHOLD here because we are
        // only considering equal nodes at the beginning or end of the
        // file. There's no risk we split unrelated regions with a
        // trivial unchanged node in the middle.
        if lhs_node.content_id() == rhs_node.content_id() {
            lhs_node.set_change_deep(ChangeKind::Unchanged(rhs_node));
            rhs_node.set_change_deep(ChangeKind::Unchanged(lhs_node));

            changed = true;
            lhs_nodes = &lhs_nodes[1..];
            rhs_nodes = &rhs_nodes[1..];
        } else {
            break;
        }
    }

    while let (Some(lhs_node), Some(rhs_node)) = (lhs_nodes.last(), rhs_nodes.last()) {
        if lhs_node.content_id() == rhs_node.content_id() {
            lhs_node.set_change_deep(ChangeKind::Unchanged(rhs_node));
            rhs_node.set_change_deep(ChangeKind::Unchanged(lhs_node));

            changed = true;
            lhs_nodes = &lhs_nodes[..lhs_nodes.len() - 1];
            rhs_nodes = &rhs_nodes[..rhs_nodes.len() - 1];
        } else {
            break;
        }
    }

    if lhs_nodes.len() == 1 && rhs_nodes.len() == 1 {
        let (changed_later, lhs_nodes, rhs_nodes) =
            shrink_unchanged_delimiters(lhs_nodes, rhs_nodes);
        (changed || changed_later, lhs_nodes, rhs_nodes)
    } else {
        (changed, Vec::from(lhs_nodes), Vec::from(rhs_nodes))
    }
}
/// Skip syntax nodes at the beginning or end that are obviously
/// unchanged.
///
/// Set the ChangeKind on the definitely changed nodes, and return the
/// nodes that may contain changes.
Skip syntax nodes at the beginning or end that are obviously
unchanged.

Set the ChangeKind on the definitely changed nodes, and return the
nodes that may contain changes.
Skip syntax nodes at the beginning or end that are obviously unchanged . Set the ChangeKind on the definitely changed nodes and return the nodes that may contain changes .
fn shrink_unchanged_at_ends<'a>(
    lhs_nodes: &[&'a Syntax<'a>],
    rhs_nodes: &[&'a Syntax<'a>],
) -> (bool, Vec<&'a Syntax<'a>>, Vec<&'a Syntax<'a>>) {
    let mut lhs_nodes = lhs_nodes;
    let mut rhs_nodes = rhs_nodes;
    let mut changed = false;
    while let (Some(lhs_node), Some(rhs_node)) = (lhs_nodes.first(), rhs_nodes.first()) {
        // We don't consider TINY_TREE_THRESHOLD here because we are
        // only considering equal nodes at the beginning or end of the
        // file. There's no risk we split unrelated regions with a
        // trivial unchanged node in the middle.
        if lhs_node.content_id() == rhs_node.content_id() {
            lhs_node.set_change_deep(ChangeKind::Unchanged(rhs_node));
            rhs_node.set_change_deep(ChangeKind::Unchanged(lhs_node));
            changed = true;
            lhs_nodes = &lhs_nodes[1..];
            rhs_nodes = &rhs_nodes[1..];
        } else {
            break;
        }
    }
    while let (Some(lhs_node), Some(rhs_node)) = (lhs_nodes.last(), rhs_nodes.last()) {
        if lhs_node.content_id() == rhs_node.content_id() {
            lhs_node.set_change_deep(ChangeKind::Unchanged(rhs_node));
            rhs_node.set_change_deep(ChangeKind::Unchanged(lhs_node));
            changed = true;
            lhs_nodes = &lhs_nodes[..lhs_nodes.len() - 1];
            rhs_nodes = &rhs_nodes[..rhs_nodes.len() - 1];
        } else {
            break;
        }
    }
    if lhs_nodes.len() == 1 && rhs_nodes.len() == 1 {
        let (changed_later, lhs_nodes, rhs_nodes) =
            shrink_unchanged_delimiters(lhs_nodes, rhs_nodes);
        (changed || changed_later, lhs_nodes, rhs_nodes)
    } else {
        (changed, Vec::from(lhs_nodes), Vec::from(rhs_nodes))
    }
}
fn shrink_unchanged_at_ends < ' a > ( lhs_nodes : & [ & ' a Syntax < ' a > ] , rhs_nodes : & [ & ' a Syntax < ' a > ] , ) -> ( bool , Vec < & ' a Syntax < ' a > > , Vec < & ' a Syntax < ' a > > ) { let mut lhs_nodes = lhs_nodes ; let mut rhs_nodes = rhs_nodes ; let mut changed = false ; while let ( Some ( lhs_node ) , Some ( rhs_node ) ) = ( lhs_nodes . first ( ) , rhs_nodes . first ( ) ) { // We don't consider TINY_TREE_THRESHOLD here because we are // only considering equal nodes at the beginning or end of the // file. There's no risk we split unrelated regions with a // trivial unchanged node in the middle. if lhs_node . content_id ( ) == rhs_node . content_id ( ) { lhs_node . set_change_deep ( ChangeKind :: Unchanged ( rhs_node ) ) ; rhs_node . set_change_deep ( ChangeKind :: Unchanged ( lhs_node ) ) ; changed = true ; lhs_nodes = & lhs_nodes [ 1 .. ] ; rhs_nodes = & rhs_nodes [ 1 .. ] ; } else { break ; } } while let ( Some ( lhs_node ) , Some ( rhs_node ) ) = ( lhs_nodes . last ( ) , rhs_nodes . last ( ) ) { if lhs_node . content_id ( ) == rhs_node . content_id ( ) { lhs_node . set_change_deep ( ChangeKind :: Unchanged ( rhs_node ) ) ; rhs_node . set_change_deep ( ChangeKind :: Unchanged ( lhs_node ) ) ; changed = true ; lhs_nodes = & lhs_nodes [ .. lhs_nodes . len ( ) - 1 ] ; rhs_nodes = & rhs_nodes [ .. rhs_nodes . len ( ) - 1 ] ; } else { break ; } } if lhs_nodes . len ( ) == 1 && rhs_nodes . len ( ) == 1 { let ( changed_later , lhs_nodes , rhs_nodes ) = shrink_unchanged_delimiters ( lhs_nodes , rhs_nodes ) ; ( changed || changed_later , lhs_nodes , rhs_nodes ) } else { ( changed , Vec :: from ( lhs_nodes ) , Vec :: from ( rhs_nodes ) ) } }
Skip syntax nodes at the beginning or end that are obviously
unchanged.
Skip syntax nodes at the beginning or end that are obviously unchanged .
lhs_nodes
&[&'a Syntax<'a>]
rhs_nodes
&[&'a Syntax<'a>]