Skip to content

Commit

Permalink
Avoid one allocation
Browse files Browse the repository at this point in the history
Signed-off-by: Yadunund <[email protected]>
  • Loading branch information
Yadunund committed Jun 24, 2024
1 parent 3854660 commit 50d7339
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions rmw_zenoh_cpp/src/rmw_zenoh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,13 @@ z_owned_keyexpr_t ros_topic_name_to_zenoh_key(
const char * const topic_type,
const char * const type_hash)
{
const std::string keyexpr_str = std::to_string(domain_id) + "/" +
strip_slashes(topic_name) + "/" +
std::string(topic_type) + "/" +
std::string(type_hash);
std::string keyexpr_str = std::to_string(domain_id);
keyexpr_str += "/";
keyexpr_str += strip_slashes(topic_name);
keyexpr_str += "/";
keyexpr_str += topic_type;
keyexpr_str += "/";
keyexpr_str += type_hash;

return z_keyexpr_new(keyexpr_str.c_str());
}
Expand Down

0 comments on commit 50d7339

Please sign in to comment.