mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2024-12-13 09:32:47 +00:00
(split_interval_right): Make sure to call
balance_possible_root_interval in case an interval doesn't have a right child, because otherwise the interval tree might degenerate into a list. (split_interval_left): Ditto if an interval hasn't a left child.
This commit is contained in:
parent
ab2d0cdb53
commit
cc6e2aaa2a
@ -478,17 +478,17 @@ split_interval_right (interval, offset)
|
||||
{
|
||||
interval->right = new;
|
||||
new->total_length = new_length;
|
||||
|
||||
return new;
|
||||
}
|
||||
|
||||
/* Insert the new node between INTERVAL and its right child. */
|
||||
new->right = interval->right;
|
||||
interval->right->parent = new;
|
||||
interval->right = new;
|
||||
new->total_length = new_length + new->right->total_length;
|
||||
|
||||
balance_an_interval (new);
|
||||
else
|
||||
{
|
||||
/* Insert the new node between INTERVAL and its right child. */
|
||||
new->right = interval->right;
|
||||
interval->right->parent = new;
|
||||
interval->right = new;
|
||||
new->total_length = new_length + new->right->total_length;
|
||||
balance_an_interval (new);
|
||||
}
|
||||
|
||||
balance_possible_root_interval (interval);
|
||||
|
||||
return new;
|
||||
@ -524,17 +524,17 @@ split_interval_left (interval, offset)
|
||||
{
|
||||
interval->left = new;
|
||||
new->total_length = new_length;
|
||||
|
||||
return new;
|
||||
}
|
||||
|
||||
/* Insert the new node between INTERVAL and its left child. */
|
||||
new->left = interval->left;
|
||||
new->left->parent = new;
|
||||
interval->left = new;
|
||||
new->total_length = new_length + new->left->total_length;
|
||||
|
||||
balance_an_interval (new);
|
||||
else
|
||||
{
|
||||
/* Insert the new node between INTERVAL and its left child. */
|
||||
new->left = interval->left;
|
||||
new->left->parent = new;
|
||||
interval->left = new;
|
||||
new->total_length = new_length + new->left->total_length;
|
||||
balance_an_interval (new);
|
||||
}
|
||||
|
||||
balance_possible_root_interval (interval);
|
||||
|
||||
return new;
|
||||
|
Loading…
Reference in New Issue
Block a user