Mercurial > emacs
changeset 20908:516b224be85a
(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.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Mon, 16 Feb 1998 23:46:08 +0000 |
parents | 9a55a557cb5a |
children | 542ae65815fb |
files | src/intervals.c |
diffstat | 1 files changed, 20 insertions(+), 20 deletions(-) [+] |
line wrap: on
line diff
--- a/src/intervals.c Mon Feb 16 05:42:08 1998 +0000 +++ b/src/intervals.c Mon Feb 16 23:46:08 1998 +0000 @@ -478,17 +478,17 @@ { 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 @@ { 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;