diff options
author | Gedare Bloom <gedare@rtems.org> | 2012-03-29 20:41:34 -0400 |
---|---|---|
committer | Gedare Bloom <gedare@rtems.org> | 2012-03-29 20:42:36 -0400 |
commit | 890358f4f7cb8bc3ac3dcbbe5805e8285c92444a (patch) | |
tree | b939b17a28d00fe2a094bb2f64778da355f7bc40 /cpukit/score/inline/rtems/score/rbtree.inl | |
parent | PC386 - Add files missed in previous commit (diff) | |
download | rtems-890358f4f7cb8bc3ac3dcbbe5805e8285c92444a.tar.bz2 |
PR1994: RBTree Compare Result Change
Change the meaning of the compare result to simplify comparison of
integer keys.
Diffstat (limited to 'cpukit/score/inline/rtems/score/rbtree.inl')
-rw-r--r-- | cpukit/score/inline/rtems/score/rbtree.inl | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/cpukit/score/inline/rtems/score/rbtree.inl b/cpukit/score/inline/rtems/score/rbtree.inl index ef653e5628..c74726a30e 100644 --- a/cpukit/score/inline/rtems/score/rbtree.inl +++ b/cpukit/score/inline/rtems/score/rbtree.inl @@ -324,6 +324,25 @@ RTEMS_INLINE_ROUTINE RBTree_Control *_RBTree_Find_header_unprotected( return (RBTree_Control*)the_node; } +RTEMS_INLINE_ROUTINE bool _RBTree_Is_equal( int compare_result ) +{ + return compare_result == 0; +} + +RTEMS_INLINE_ROUTINE bool _RBTree_Is_greater( + int compare_result +) +{ + return compare_result > 0; +} + +RTEMS_INLINE_ROUTINE bool _RBTree_Is_lesser( + int compare_result +) +{ + return compare_result < 0; +} + /** @brief Find the node with given key in the tree * * This function returns a pointer to the node in @a the_rbtree @@ -343,13 +362,13 @@ RTEMS_INLINE_ROUTINE RBTree_Node *_RBTree_Find_unprotected( int compare_result; while (iter_node) { compare_result = the_rbtree->compare_function(the_node, iter_node); - if (compare_result == 0) { + if ( _RBTree_Is_equal( compare_result ) ) { found = iter_node; if ( the_rbtree->is_unique ) break; } - RBTree_Direction dir = (compare_result == 1); + RBTree_Direction dir = _RBTree_Is_greater( compare_result ); iter_node = iter_node->child[dir]; } /* while(iter_node) */ |