From 02b3836134cbb25e20eac022495dc319a2a3cddb Mon Sep 17 00:00:00 2001 From: Chris Lalancette Date: Tue, 13 Jun 2023 12:22:59 -0400 Subject: [PATCH] Get rid of unnecessary checks in composable_node_container. (#364) valid_composable_nodes is a local variable that we know is a list. So we can just do the idiomatic Python thing and check with a simple "if" statement. This is also faster. Signed-off-by: Chris Lalancette --- launch_ros/launch_ros/actions/composable_node_container.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/launch_ros/launch_ros/actions/composable_node_container.py b/launch_ros/launch_ros/actions/composable_node_container.py index 8740137e..d4fecb5a 100644 --- a/launch_ros/launch_ros/actions/composable_node_container.py +++ b/launch_ros/launch_ros/actions/composable_node_container.py @@ -85,10 +85,7 @@ def execute(self, context: LaunchContext) -> Optional[List[Action]]: if node_object.condition() is None or node_object.condition().evaluate(context): valid_composable_nodes.append(node_object) - if ( - valid_composable_nodes is not None and - len(valid_composable_nodes) > 0 - ): + if valid_composable_nodes: from .load_composable_nodes import LoadComposableNodes # Perform load action once the container has started. load_actions = [