From 76c41bb0487a70411f17e3990630b178c337929c Mon Sep 17 00:00:00 2001 From: Dirk Thomas Date: Thu, 16 Jul 2015 22:30:16 -0700 Subject: [PATCH] pass strings as const reference --- rclcpp/include/rclcpp/node.hpp | 8 ++++---- rclcpp/include/rclcpp/node_impl.hpp | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/rclcpp/include/rclcpp/node.hpp b/rclcpp/include/rclcpp/node.hpp index 602316a..0885d70 100644 --- a/rclcpp/include/rclcpp/node.hpp +++ b/rclcpp/include/rclcpp/node.hpp @@ -102,9 +102,9 @@ public: RCLCPP_MAKE_SHARED_DEFINITIONS(Node); /* Create a node based on the node name. */ - Node(std::string node_name); + Node(const std::string & node_name); /* Create a node based on the node name and a rclcpp::context::Context. */ - Node(std::string node_name, rclcpp::context::Context::SharedPtr context); + Node(const std::string & node_name, rclcpp::context::Context::SharedPtr context); /* Get the name of the node. */ const std::string & @@ -117,13 +117,13 @@ public: /* Create and return a Publisher. */ template rclcpp::publisher::Publisher::SharedPtr - create_publisher(std::string topic_name, size_t queue_size); + create_publisher(const std::string & topic_name, size_t queue_size); /* Create and return a Subscription. */ template typename rclcpp::subscription::Subscription::SharedPtr create_subscription( - std::string topic_name, + const std::string & topic_name, size_t queue_size, std::function &)> callback, rclcpp::callback_group::CallbackGroup::SharedPtr group = nullptr, diff --git a/rclcpp/include/rclcpp/node_impl.hpp b/rclcpp/include/rclcpp/node_impl.hpp index 7e18dae..0044fd3 100644 --- a/rclcpp/include/rclcpp/node_impl.hpp +++ b/rclcpp/include/rclcpp/node_impl.hpp @@ -38,11 +38,11 @@ using namespace rclcpp::node; using rclcpp::contexts::default_context::DefaultContext; -Node::Node(std::string node_name) +Node::Node(const std::string & node_name) : Node(node_name, DefaultContext::make_shared()) {} -Node::Node(std::string node_name, context::Context::SharedPtr context) +Node::Node(const std::string & node_name, context::Context::SharedPtr context) : name_(node_name), context_(context), number_of_subscriptions_(0), number_of_timers_(0), number_of_services_(0) { @@ -89,7 +89,7 @@ Node::create_callback_group( template publisher::Publisher::SharedPtr -Node::create_publisher(std::string topic_name, size_t queue_size) +Node::create_publisher(const std::string & topic_name, size_t queue_size) { using rosidl_generator_cpp::get_message_type_support_handle; auto type_support_handle = get_message_type_support_handle(); @@ -122,7 +122,7 @@ Node::group_in_node(callback_group::CallbackGroup::SharedPtr & group) template typename subscription::Subscription::SharedPtr Node::create_subscription( - std::string topic_name, + const std::string & topic_name, size_t queue_size, std::function &)> callback, rclcpp::callback_group::CallbackGroup::SharedPtr group,