fn diff_keyed_ends(
        &mut self,

        old: &'bump [VNode<'bump>],
        new: &'bump [VNode<'bump>],
    ) -> Option<(usize, usize)> {
        let mut left_offset = 0;

        for (old, new) in old.iter().zip(new.iter()) {
            // abort early if we finally run into nodes with different keys
            if old.key() != new.key() {
                break;
            }
            self.stack.push(DiffInstruction::Diff { old, new });
            left_offset += 1;
        }

        // If that was all of the old children, then create and append the remaining
        // new children and we're finished.
        if left_offset == old.len() {
            self.stack.create_children(
                &new[left_offset..],
                MountType::InsertAfter {
                    other_node: old.last().unwrap(),
                },
            );
            return None;
        }

        // And if that was all of the new children, then remove all of the remaining
        // old children and we're finished.
        if left_offset == new.len() {
            self.remove_nodes(&old[left_offset..], true);
            return None;
        }

        // if the shared prefix is less than either length, then we need to walk backwards
        let mut right_offset = 0;
        for (old, new) in old.iter().rev().zip(new.iter().rev()) {
            // abort early if we finally run into nodes with different keys
            if old.key() != new.key() {
                break;
            }
            self.diff_node(old, new);
            right_offset += 1;
        }

        Some((left_offset, right_offset))
    }
/// Diff both ends of the children that share keys.
///
/// Returns a left offset and right offset of that indicates a smaller section to pass onto the middle diffing.
///
/// If there is no offset, then this function returns None and the diffing is complete.
Diff both ends of the children that share keys.
Returns a left offset and right offset of that indicates a smaller section to pass onto the middle diffing.

If there is no offset, then this function returns None and the diffing is complete.
Diff both ends of the children that share keys . Returns a left offset and right offset of that indicates a smaller section to pass onto the middle diffing . If there is no offset then this function returns None and the diffing is complete .
fn diff_keyed_ends(
        &mut self,
        old: &'bump [VNode<'bump>],
        new: &'bump [VNode<'bump>],
    ) -> Option<(usize, usize)> {
        let mut left_offset = 0;
        for (old, new) in old.iter().zip(new.iter()) {
            // abort early if we finally run into nodes with different keys
            if old.key() != new.key() {
                break;
            }
            self.stack.push(DiffInstruction::Diff { old, new });
            left_offset += 1;
        }
        // If that was all of the old children, then create and append the remaining
        // new children and we're finished.
        if left_offset == old.len() {
            self.stack.create_children(
                &new[left_offset..],
                MountType::InsertAfter {
                    other_node: old.last().unwrap(),
                },
            );
            return None;
        }
        // And if that was all of the new children, then remove all of the remaining
        // old children and we're finished.
        if left_offset == new.len() {
            self.remove_nodes(&old[left_offset..], true);
            return None;
        }
        // if the shared prefix is less than either length, then we need to walk backwards
        let mut right_offset = 0;
        for (old, new) in old.iter().rev().zip(new.iter().rev()) {
            // abort early if we finally run into nodes with different keys
            if old.key() != new.key() {
                break;
            }
            self.diff_node(old, new);
            right_offset += 1;
        }
        Some((left_offset, right_offset))
    }
fn diff_keyed_ends ( & mut self , old : & ' bump [ VNode < ' bump > ] , new : & ' bump [ VNode < ' bump > ] , ) -> Option < ( usize , usize ) > { let mut left_offset = 0 ; for ( old , new ) in old . iter ( ) . zip ( new . iter ( ) ) { // abort early if we finally run into nodes with different keys if old . key ( ) != new . key ( ) { break ; } self . stack . push ( DiffInstruction :: Diff { old , new } ) ; left_offset += 1 ; } // If that was all of the old children, then create and append the remaining // new children and we're finished. if left_offset == old . len ( ) { self . stack . create_children ( & new [ left_offset .. ] , MountType :: InsertAfter { other_node : old . last ( ) . unwrap ( ) , } , ) ; return None ; } // And if that was all of the new children, then remove all of the remaining // old children and we're finished. if left_offset == new . len ( ) { self . remove_nodes ( & old [ left_offset .. ] , true ) ; return None ; } // if the shared prefix is less than either length, then we need to walk backwards let mut right_offset = 0 ; for ( old , new ) in old . iter ( ) . rev ( ) . zip ( new . iter ( ) . rev ( ) ) { // abort early if we finally run into nodes with different keys if old . key ( ) != new . key ( ) { break ; } self . diff_node ( old , new ) ; right_offset += 1 ; } Some ( ( left_offset , right_offset ) ) }
Diff both ends of the children that share keys.
Diff both ends of the children that share keys .
&mut self
old
&'bump [VNode<'bump>]
new
&'bump [VNode<'bump>]