From e2e56a87ae22d32504e0fcf2138cc70842128848 Mon Sep 17 00:00:00 2001 From: Takashi Sato Date: Tue, 17 Dec 2024 19:14:38 +0900 Subject: [PATCH] Refactor get_name methods to return const references for improved performance --- .../include/hardware_interface/loaned_command_interface.hpp | 4 ++-- .../include/hardware_interface/loaned_state_interface.hpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/hardware_interface/include/hardware_interface/loaned_command_interface.hpp b/hardware_interface/include/hardware_interface/loaned_command_interface.hpp index 6013dea778..fb2cfb4e52 100644 --- a/hardware_interface/include/hardware_interface/loaned_command_interface.hpp +++ b/hardware_interface/include/hardware_interface/loaned_command_interface.hpp @@ -81,12 +81,12 @@ class LoanedCommandInterface } } - const std::string get_name() const { return command_interface_.get_name(); } + const std::string & get_name() const { return command_interface_.get_name(); } const std::string & get_interface_name() const { return command_interface_.get_interface_name(); } [[deprecated( - "Replaced by get_name method, which is semantically more correct")]] const std::string + "Replaced by get_name method, which is semantically more correct")]] const std::string & get_full_name() const { return command_interface_.get_name(); diff --git a/hardware_interface/include/hardware_interface/loaned_state_interface.hpp b/hardware_interface/include/hardware_interface/loaned_state_interface.hpp index 3ebc8c7ca0..89b1207415 100644 --- a/hardware_interface/include/hardware_interface/loaned_state_interface.hpp +++ b/hardware_interface/include/hardware_interface/loaned_state_interface.hpp @@ -75,12 +75,12 @@ class LoanedStateInterface } } - const std::string get_name() const { return state_interface_.get_name(); } + const std::string & get_name() const { return state_interface_.get_name(); } const std::string & get_interface_name() const { return state_interface_.get_interface_name(); } [[deprecated( - "Replaced by get_name method, which is semantically more correct")]] const std::string + "Replaced by get_name method, which is semantically more correct")]] const std::string & get_full_name() const { return state_interface_.get_name();