diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 2011-08-02 13:37:21 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 2011-08-02 13:37:21 +0000 |
commit | d188381a6b4696526c1e427de44b732821aa5e73 (patch) | |
tree | 5c1676b38735cb6741c3f6f08db3995222ffe4c5 /cpukit/score/src/rbtreeextract.c | |
parent | 2011-08-02 Ricardo Aguirre <el.mastin@ymail.com> (diff) | |
download | rtems-d188381a6b4696526c1e427de44b732821aa5e73.tar.bz2 |
2011-08-02 Petr Benes <benesp16@fel.cvut.cz>
PR 1861/cpukit
* score/src/rbtreeextract.c: Remove redundant code.
Diffstat (limited to 'cpukit/score/src/rbtreeextract.c')
-rw-r--r-- | cpukit/score/src/rbtreeextract.c | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/cpukit/score/src/rbtreeextract.c b/cpukit/score/src/rbtreeextract.c index 9227cadfc3..b54fc4f7af 100644 --- a/cpukit/score/src/rbtreeextract.c +++ b/cpukit/score/src/rbtreeextract.c @@ -54,8 +54,7 @@ void _RBTree_Extract_validate_unprotected( } /* sibling is black, see if both of its children are also black. */ - if (sibling && - !_RBTree_Is_red(sibling->child[RBT_RIGHT]) && + if (!_RBTree_Is_red(sibling->child[RBT_RIGHT]) && !_RBTree_Is_red(sibling->child[RBT_LEFT])) { sibling->color = RBT_RED; if (_RBTree_Is_red(parent)) { @@ -65,7 +64,7 @@ void _RBTree_Extract_validate_unprotected( the_node = parent; /* done if parent is red */ parent = the_node->parent; sibling = _RBTree_Sibling(the_node); - } else if(sibling) { + } else { /* at least one of sibling's children is red. we now proceed in two * cases, either the_node is to the left or the right of the parent. * In both cases, first check if one of sibling's children is black, @@ -105,7 +104,7 @@ void _RBTree_Extract_unprotected( RBTree_Color victim_color; RBTree_Direction dir; - if(!the_node) return; + if (!the_node) return; /* check if min needs to be updated */ if (the_node == the_rbtree->first[RBT_LEFT]) { @@ -147,7 +146,7 @@ void _RBTree_Extract_unprotected( * should become NULL. This may cause the coloring to be violated. * For now we store the color of the node being deleted in victim_color. */ - leaf = target->child[RBT_LEFT]; + leaf = target->child[RBT_LEFT]; if(leaf) { leaf->parent = target->parent; } else { @@ -199,17 +198,14 @@ void _RBTree_Extract_unprotected( } /* fix coloring. leaf has moved up the tree. The color of the deleted - * node is in victim_color. There are three cases: + * node is in victim_color. There are two cases: * 1. Deleted a red node, its child must be black. Nothing must be done. - * 2. Deleted a black node and the child is red. Paint child black. - * 3. Deleted a black node and its child is black. This requires some - * care and rotations. + * 2. Deleted a black node, its child must be red. Paint child black. */ if (victim_color == RBT_BLACK) { /* eliminate case 1 */ - if (_RBTree_Is_red(leaf)) + if (leaf) { leaf->color = RBT_BLACK; /* case 2 */ - else if(leaf) - _RBTree_Extract_validate_unprotected(leaf); /* case 3 */ + } } /* Wipe the_node */ |