Skip to content

Commit

Permalink
Use empty() to check for an empty string (#247)
Browse files Browse the repository at this point in the history
* rmw_fastrtps_shared_cpp/src/demangle.cpp:
    * rmw_fastrtps_shared_cpp/src/rmw_node_info_and_types.cpp:
    * rmw_fastrtps_shared_cpp/src/rmw_service_names_and_types.cpp:
  • Loading branch information
jwillemsen authored and sloretz committed Dec 21, 2018
1 parent dcc7ea2 commit 8cf6e3e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion rmw_fastrtps_shared_cpp/src/demangle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ std::string
_demangle_service_from_topic(const std::string & topic_name)
{
std::string prefix = _get_ros_prefix_if_exists(topic_name);
if (!prefix.length()) {
if (prefix.empty()) {
// not a ROS topic or service
return "";
}
Expand Down
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 @@ -416,13 +416,13 @@ __rmw_get_service_names_and_types_by_node(
if (node_topics != topic_cache.getParticipantToTopics().end()) {
for (auto & topic_pair : node_topics->second) {
std::string service_name = _demangle_service_from_topic(topic_pair.first);
if (!service_name.length()) {
if (service_name.empty()) {
// not a service
continue;
}
for (auto & itt : topic_pair.second) {
std::string service_type = _demangle_service_type_only(itt);
if (service_type.length()) {
if (!service_type.empty()) {
services[service_name].insert(service_type);
}
}
Expand Down
4 changes: 2 additions & 2 deletions rmw_fastrtps_shared_cpp/src/rmw_service_names_and_types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,13 @@ __rmw_get_service_names_and_types(
std::lock_guard<std::mutex> guard(topic_cache.getMutex());
for (auto it : topic_cache.getTopicToTypes()) {
std::string service_name = _demangle_service_from_topic(it.first);
if (!service_name.length()) {
if (service_name.empty()) {
// not a service
continue;
}
for (auto & itt : it.second) {
std::string service_type = _demangle_service_type_only(itt);
if (service_type.length()) {
if (!service_type.empty()) {
services[service_name].insert(service_type);
}
}
Expand Down

0 comments on commit 8cf6e3e

Please sign in to comment.