Changeset 0ef6e3bf in rtems


Ignore:
Timestamp:
07/24/14 15:50:58 (9 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, 5, master
Children:
0b9fe3ec
Parents:
993f5ac
git-author:
Sebastian Huber <sebastian.huber@…> (07/24/14 15:50:58)
git-committer:
Sebastian Huber <sebastian.huber@…> (08/07/14 13:59:29)
Message:

rbtree: Simplify _RBTree_Extract()

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpukit/score/src/rbtreeextract.c

    r993f5ac r0ef6e3bf  
    2424{
    2525  RBTree_Node     *parent;
    26   RBTree_Direction dir;
    2726
    2827  parent = the_node->parent;
     
    4140     */
    4241    if ( _RBTree_Is_red( sibling ) ) {
     42      RBTree_Direction dir = _RBTree_Direction( the_node, parent );
     43      RBTree_Direction opp_dir = _RBTree_Opposite_direction( dir );
     44
    4345      parent->color = RBT_RED;
    4446      sibling->color = RBT_BLACK;
    45       dir = the_node != parent->child[ 0 ];
    4647      _RBTree_Rotate( parent, dir );
    47       sibling = parent->child[ _RBTree_Opposite_direction( dir ) ];
     48      sibling = parent->child[ opp_dir ];
    4849    }
    4950
     
    6768       * Then switch the sibling and parent colors, and rotate through parent.
    6869       */
    69       dir = the_node != parent->child[ 0 ];
     70      RBTree_Direction dir = _RBTree_Direction( the_node, parent );
     71      RBTree_Direction opp_dir = _RBTree_Opposite_direction( dir );
    7072
    7173      if (
    72         !_RBTree_Is_red( sibling->child[ _RBTree_Opposite_direction( dir ) ] )
     74        !_RBTree_Is_red( sibling->child[ opp_dir ] )
    7375      ) {
    7476        sibling->color = RBT_RED;
    7577        sibling->child[ dir ]->color = RBT_BLACK;
    76         _RBTree_Rotate( sibling, _RBTree_Opposite_direction( dir ) );
    77         sibling = parent->child[ _RBTree_Opposite_direction( dir ) ];
     78        _RBTree_Rotate( sibling, opp_dir );
     79        sibling = parent->child[ opp_dir ];
    7880      }
    7981
    8082      sibling->color = parent->color;
    8183      parent->color = RBT_BLACK;
    82       sibling->child[ _RBTree_Opposite_direction( dir ) ]->color = RBT_BLACK;
     84      sibling->child[ opp_dir ]->color = RBT_BLACK;
    8385      _RBTree_Rotate( parent, dir );
    8486      break; /* done */
Note: See TracChangeset for help on using the changeset viewer.