diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2015-09-02 15:02:27 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2015-09-02 15:02:27 +0200 |
commit | 8c25e0460631f899a5cd41d125efa7dcae84705c (patch) | |
tree | d218cbe9de453cf6340a2f41a742773b4cb46476 /cpukit/score/src/threadqops.c | |
parent | posix: glibc compatibility (diff) | |
download | rtems-8c25e0460631f899a5cd41d125efa7dcae84705c.tar.bz2 |
score: Optimize thread queue first operation
In case the thread queue heads exist, then the queue is not empty. See
_Thread_queue_First_locked().
Diffstat (limited to 'cpukit/score/src/threadqops.c')
-rw-r--r-- | cpukit/score/src/threadqops.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/cpukit/score/src/threadqops.c b/cpukit/score/src/threadqops.c index c9e2b5d9ba..d9dc94440e 100644 --- a/cpukit/score/src/threadqops.c +++ b/cpukit/score/src/threadqops.c @@ -142,9 +142,12 @@ static Thread_Control *_Thread_queue_FIFO_first( ) { Chain_Control *fifo = &heads->Heads.Fifo; + Chain_Node *first; - return _Chain_Is_empty( fifo ) ? - NULL : THREAD_CHAIN_NODE_TO_THREAD( _Chain_First( fifo ) ); + _Assert( !_Chain_Is_empty( fifo ) ); + first = _Chain_First( fifo ); + + return THREAD_CHAIN_NODE_TO_THREAD( first ); } static void _Thread_queue_Priority_priority_change( @@ -229,11 +232,13 @@ static Thread_Control *_Thread_queue_Priority_first( Thread_queue_Heads *heads ) { - RBTree_Node *first; + RBTree_Control *priority_queue = &heads->Heads.Priority; + RBTree_Node *first; - first = _RBTree_Minimum( &heads->Heads.Priority ); + _Assert( !_RBTree_Is_empty( priority_queue ) ); + first = _RBTree_Minimum( priority_queue ); - return first != NULL ? THREAD_RBTREE_NODE_TO_THREAD( first ) : NULL; + return THREAD_RBTREE_NODE_TO_THREAD( first ); } const Thread_queue_Operations _Thread_queue_Operations_default = { |