[PATCH 04/45] score: Optimize _Thread_queue_Compare_priority()

Sebastian Huber sebastian.huber at embedded-brains.de
Fri May 15 11:41:04 UTC 2015


---
 cpukit/score/src/threadq.c | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/cpukit/score/src/threadq.c b/cpukit/score/src/threadq.c
index bdd380d..0ea0c82 100644
--- a/cpukit/score/src/threadq.c
+++ b/cpukit/score/src/threadq.c
@@ -29,19 +29,20 @@ RBTree_Compare_result _Thread_queue_Compare_priority(
   const RBTree_Node *right
 )
 {
-  Priority_Control left_priority =
-    THREAD_RBTREE_NODE_TO_THREAD( left )->current_priority;
-  Priority_Control right_priority =
-    THREAD_RBTREE_NODE_TO_THREAD( right )->current_priority;
+  const Thread_Control *left_thread;
+  const Thread_Control *right_thread;
+  Priority_Control      left_prio;
+  Priority_Control      right_prio;
+
+  left_thread = THREAD_RBTREE_NODE_TO_THREAD( left );
+  right_thread = THREAD_RBTREE_NODE_TO_THREAD( right );
+  left_prio = left_thread->current_priority;
+  right_prio = right_thread->current_priority;
 
   /*
    * SuperCore priorities use lower numbers to indicate greater importance.
    */
-  if ( left_priority == right_priority )
-    return 0;
-  if ( left_priority < right_priority )
-    return -1;
-  return 1;
+  return ( left_prio > right_prio ) - ( left_prio < right_prio );
 }
 
 void _Thread_queue_Initialize(
-- 
1.8.4.5




More information about the devel mailing list