pub fn fix_tree_seam(&mut self, char_idx: usize) -> bool {
        if let Node::Internal(ref mut children) = *self {
            let mut did_stuff = false;
            loop {
                // Do merging
                if children.len() > 1 {
                    let (child_i, start_info) = children.search_char_idx(char_idx);
                    let end_info = start_info + children.info()[child_i];

                    if end_info.chars as usize == char_idx && (child_i + 1) < children.len() {
                        let do_merge = match *children.nodes()[child_i] {
                            Node::Leaf(ref text) => text.len() < MIN_BYTES,
                            Node::Internal(ref children2) => children2.len() < MIN_CHILDREN,
                        } || match *children.nodes()[child_i + 1] {
                            Node::Leaf(ref text) => text.len() < MIN_BYTES,
                            Node::Internal(ref children2) => children2.len() < MIN_CHILDREN,
                        };

                        if do_merge {
                            did_stuff |= children.merge_distribute(child_i, child_i + 1);
                        }
                    } else {
                        let do_merge = match *children.nodes()[child_i] {
                            Node::Leaf(ref text) => text.len() < MIN_BYTES,
                            Node::Internal(ref children2) => children2.len() < MIN_CHILDREN,
                        };

                        if do_merge {
                            if child_i == 0 {
                                did_stuff |= children.merge_distribute(0, 1);
                            } else {
                                did_stuff |= children.merge_distribute(child_i - 1, child_i);
                            }
                        }
                    }
                }

                // Do recursion
                let (child_i, start_info) = children.search_char_idx(char_idx);
                let end_info = start_info + children.info()[child_i];

                if end_info.chars as usize == char_idx && (child_i + 1) < children.len() {
                    let tmp = children.info()[child_i].chars as usize;
                    let effect_1 =
                        Arc::make_mut(&mut children.nodes_mut()[child_i]).fix_tree_seam(tmp);
                    let effect_2 =
                        Arc::make_mut(&mut children.nodes_mut()[child_i + 1]).fix_tree_seam(0);
                    if (!effect_1) && (!effect_2) {
                        break;
                    }
                } else if !Arc::make_mut(&mut children.nodes_mut()[child_i])
                    .fix_tree_seam(char_idx - start_info.chars as usize)
                {
                    break;
                }
            }
            debug_assert!(children.is_info_accurate());
            did_stuff
        } else {
            false
        }
    }
/// Fixes up the tree after remove_char_range() or Rope::append().
///
/// Takes the char index of the start of the removal range.
///
/// Returns whether it did anything or not that would affect the
/// parent. True: did stuff, false: didn't do stuff
Fixes up the tree after remove_char_range() or Rope::append().
Takes the char index of the start of the removal range.

Returns whether it did anything or not that would affect the
parent. True: did stuff, false: didn't do stuff
Fixes up the tree after remove_char_range () or Rope :: append () . Takes the char index of the start of the removal range . Returns whether it did anything or not that would affect the parent . True : did stuff false : didn ' t do stuff
pub fn fix_tree_seam(&mut self, char_idx: usize) -> bool {
        if let Node::Internal(ref mut children) = *self {
            let mut did_stuff = false;
            loop {
                // Do merging
                if children.len() > 1 {
                    let (child_i, start_info) = children.search_char_idx(char_idx);
                    let end_info = start_info + children.info()[child_i];
                    if end_info.chars as usize == char_idx && (child_i + 1) < children.len() {
                        let do_merge = match *children.nodes()[child_i] {
                            Node::Leaf(ref text) => text.len() < MIN_BYTES,
                            Node::Internal(ref children2) => children2.len() < MIN_CHILDREN,
                        } || match *children.nodes()[child_i + 1] {
                            Node::Leaf(ref text) => text.len() < MIN_BYTES,
                            Node::Internal(ref children2) => children2.len() < MIN_CHILDREN,
                        };
                        if do_merge {
                            did_stuff |= children.merge_distribute(child_i, child_i + 1);
                        }
                    } else {
                        let do_merge = match *children.nodes()[child_i] {
                            Node::Leaf(ref text) => text.len() < MIN_BYTES,
                            Node::Internal(ref children2) => children2.len() < MIN_CHILDREN,
                        };
                        if do_merge {
                            if child_i == 0 {
                                did_stuff |= children.merge_distribute(0, 1);
                            } else {
                                did_stuff |= children.merge_distribute(child_i - 1, child_i);
                            }
                        }
                    }
                }
                // Do recursion
                let (child_i, start_info) = children.search_char_idx(char_idx);
                let end_info = start_info + children.info()[child_i];
                if end_info.chars as usize == char_idx && (child_i + 1) < children.len() {
                    let tmp = children.info()[child_i].chars as usize;
                    let effect_1 =
                        Arc::make_mut(&mut children.nodes_mut()[child_i]).fix_tree_seam(tmp);
                    let effect_2 =
                        Arc::make_mut(&mut children.nodes_mut()[child_i + 1]).fix_tree_seam(0);
                    if (!effect_1) && (!effect_2) {
                        break;
                    }
                } else if !Arc::make_mut(&mut children.nodes_mut()[child_i])
                    .fix_tree_seam(char_idx - start_info.chars as usize)
                {
                    break;
                }
            }
            debug_assert!(children.is_info_accurate());
            did_stuff
        } else {
            false
        }
    }
pub fn fix_tree_seam ( & mut self , char_idx : usize ) -> bool { if let Node :: Internal ( ref mut children ) = * self { let mut did_stuff = false ; loop { // Do merging if children . len ( ) > 1 { let ( child_i , start_info ) = children . search_char_idx ( char_idx ) ; let end_info = start_info + children . info ( ) [ child_i ] ; if end_info . chars as usize == char_idx && ( child_i + 1 ) < children . len ( ) { let do_merge = match * children . nodes ( ) [ child_i ] { Node :: Leaf ( ref text ) => text . len ( ) < MIN_BYTES , Node :: Internal ( ref children2 ) => children2 . len ( ) < MIN_CHILDREN , } || match * children . nodes ( ) [ child_i + 1 ] { Node :: Leaf ( ref text ) => text . len ( ) < MIN_BYTES , Node :: Internal ( ref children2 ) => children2 . len ( ) < MIN_CHILDREN , } ; if do_merge { did_stuff |= children . merge_distribute ( child_i , child_i + 1 ) ; } } else { let do_merge = match * children . nodes ( ) [ child_i ] { Node :: Leaf ( ref text ) => text . len ( ) < MIN_BYTES , Node :: Internal ( ref children2 ) => children2 . len ( ) < MIN_CHILDREN , } ; if do_merge { if child_i == 0 { did_stuff |= children . merge_distribute ( 0 , 1 ) ; } else { did_stuff |= children . merge_distribute ( child_i - 1 , child_i ) ; } } } } // Do recursion let ( child_i , start_info ) = children . search_char_idx ( char_idx ) ; let end_info = start_info + children . info ( ) [ child_i ] ; if end_info . chars as usize == char_idx && ( child_i + 1 ) < children . len ( ) { let tmp = children . info ( ) [ child_i ] . chars as usize ; let effect_1 = Arc :: make_mut ( & mut children . nodes_mut ( ) [ child_i ] ) . fix_tree_seam ( tmp ) ; let effect_2 = Arc :: make_mut ( & mut children . nodes_mut ( ) [ child_i + 1 ] ) . fix_tree_seam ( 0 ) ; if ( ! effect_1 ) && ( ! effect_2 ) { break ; } } else if ! Arc :: make_mut ( & mut children . nodes_mut ( ) [ child_i ] ) . fix_tree_seam ( char_idx - start_info . chars as usize ) { break ; } } debug_assert ! ( children is_info_accurate ( ) ) ; did_stuff } else { false } }
Fixes up the tree after remove_char_range() or Rope::append().
Fixes up the tree after remove_char_range () or Rope :: append () .
&mut self
char_idx
usize