From 3899bc1a4b3294306ae2fd3f8ff0ee10365d9f4b Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Sat, 24 Nov 2018 11:51:28 +0100 Subject: score: Optimize object lookup Use the maximum ID for the ID to object translation. Using the maximum ID gets rid of an additional load from the object information in _Objects_Get(). In addition, object lookups fail for every ID in case the object information is cleared to zero. This makes it a bit more robust during system startup (see new tests in spconfig02). The local table no longer needs a NULL pointer entry at array index zero. Adjust all the object iteration loops accordingly. Remove Objects_Information::minimum_id since it contains only redundant information. Add _Objects_Get_minimum_id() to get the minimum ID. Update #3621. --- cpukit/score/src/objectallocate.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'cpukit/score/src/objectallocate.c') diff --git a/cpukit/score/src/objectallocate.c b/cpukit/score/src/objectallocate.c index 81e322757c..2f991477da 100644 --- a/cpukit/score/src/objectallocate.c +++ b/cpukit/score/src/objectallocate.c @@ -62,16 +62,15 @@ Objects_Control *_Objects_Allocate_unprotected( * extend information base. */ - if ( !the_object ) { + if ( the_object == NULL ) { _Objects_Extend_information( information ); the_object = _Objects_Get_inactive( information ); } - if ( the_object ) { - uint32_t block; + if ( the_object != NULL ) { + Objects_Maximum block; - block = (uint32_t) _Objects_Get_index( the_object->id ) - - _Objects_Get_index( information->minimum_id ); + block = _Objects_Get_index( the_object->id ) - OBJECTS_INDEX_MINIMUM; block /= information->objects_per_block; information->inactive_per_block[ block ]--; -- cgit v1.2.3