[rtems commit] score: Optimize _Thread_queue_Compare_priority()
Sebastian Huber
sebh at rtems.org
Wed May 20 07:12:03 UTC 2015
Module: rtems
Branch: master
Commit: a61d38501ac25f81913f2766a64e43f8dfdba2b0
Changeset: http://git.rtems.org/rtems/commit/?id=a61d38501ac25f81913f2766a64e43f8dfdba2b0
Author: Sebastian Huber <sebastian.huber at embedded-brains.de>
Date: Fri Apr 24 10:51:24 2015 +0200
score: Optimize _Thread_queue_Compare_priority()
---
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(
More information about the vc
mailing list