Skip to content

Commit

Permalink
We can compare a std::string with a const char* using operator==, sim…
Browse files Browse the repository at this point in the history
…plifies the code (#248)

* rmw_fastrtps_shared_cpp/src/rmw_node_info_and_types.cpp:
  • Loading branch information
jwillemsen authored and sloretz committed Dec 21, 2018
1 parent 705a0c0 commit dcc7ea2
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions rmw_fastrtps_shared_cpp/src/rmw_node_info_and_types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ rmw_ret_t __get_guid_by_name(
std::set<GUID_t> nodes_in_desired_namespace;
auto namespaces = impl->listener->discovered_namespaces;
for (auto & guid_to_namespace : impl->listener->discovered_namespaces) {
if (strcmp(guid_to_namespace.second.c_str(), node_namespace) == 0) {
if (guid_to_namespace.second == node_namespace) {
nodes_in_desired_namespace.insert(guid_to_namespace.first);
}
}
Expand All @@ -74,7 +74,7 @@ rmw_ret_t __get_guid_by_name(
impl->listener->discovered_names.end(),
[node_name, &nodes_in_desired_namespace](const std::pair<const GUID_t,
std::string> & pair) {
return strcmp(pair.second.c_str(), node_name) == 0 &&
return pair.second == node_name &&
nodes_in_desired_namespace.find(pair.first) != nodes_in_desired_namespace.end();
});

Expand Down

0 comments on commit dcc7ea2

Please sign in to comment.