[rtems commit] score: Optimize _Objects_Name_to_id_u32()

Sebastian Huber sebh at rtems.org
Mon Aug 31 14:21:33 UTC 2020


Module:    rtems
Branch:    master
Commit:    1818b9a8269c4809b229c3bfa95896f067256bbe
Changeset: http://git.rtems.org/rtems/commit/?id=1818b9a8269c4809b229c3bfa95896f067256bbe

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Thu Jun 25 07:49:50 2020 +0200

score: Optimize _Objects_Name_to_id_u32()

Remove the superfluous invalid name check since the object creation
directives ensure that objects with such a name cannot exist.  Also
finding an object with such a name would be no catastrophy if it really
exists.

---

 cpukit/score/src/objectmp.c       | 1 +
 cpukit/score/src/objectnametoid.c | 4 +---
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/cpukit/score/src/objectmp.c b/cpukit/score/src/objectmp.c
index e956135..74d5530 100644
--- a/cpukit/score/src/objectmp.c
+++ b/cpukit/score/src/objectmp.c
@@ -325,6 +325,7 @@ Objects_Name_or_id_lookup_errors _Objects_MP_Global_name_search(
 
   if ( the_global_object != NULL ) {
     *the_id = the_global_object->id;
+    _Assert( the_global_object->name.name_u32 != 0 );
     status = OBJECTS_NAME_OR_ID_LOOKUP_SUCCESSFUL;
   } else {
     status = OBJECTS_INVALID_NAME;
diff --git a/cpukit/score/src/objectnametoid.c b/cpukit/score/src/objectnametoid.c
index d89e161..ba73bdb 100644
--- a/cpukit/score/src/objectnametoid.c
+++ b/cpukit/score/src/objectnametoid.c
@@ -40,9 +40,6 @@ Objects_Name_or_id_lookup_errors _Objects_Name_to_id_u32(
   if ( !id )
     return OBJECTS_INVALID_ADDRESS;
 
-  if ( name == 0 )
-    return OBJECTS_INVALID_NAME;
-
   maximum = _Objects_Get_maximum_index( information );
   search_local_node = false;
 
@@ -61,6 +58,7 @@ Objects_Name_or_id_lookup_errors _Objects_Name_to_id_u32(
 
       if ( name == the_object->name.name_u32 ) {
         *id = the_object->id;
+        _Assert( name != 0 );
         return OBJECTS_NAME_OR_ID_LOOKUP_SUCCESSFUL;
       }
     }



More information about the vc mailing list