Skip to content

Commit 8cf6e3e

Browse files
jwillemsensloretz
authored andcommitted
Use empty() to check for an empty string (#247)
* 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:
1 parent dcc7ea2 commit 8cf6e3e

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

rmw_fastrtps_shared_cpp/src/demangle.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ std::string
5252
_demangle_service_from_topic(const std::string & topic_name)
5353
{
5454
std::string prefix = _get_ros_prefix_if_exists(topic_name);
55-
if (!prefix.length()) {
55+
if (prefix.empty()) {
5656
// not a ROS topic or service
5757
return "";
5858
}

rmw_fastrtps_shared_cpp/src/rmw_node_info_and_types.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -416,13 +416,13 @@ __rmw_get_service_names_and_types_by_node(
416416
if (node_topics != topic_cache.getParticipantToTopics().end()) {
417417
for (auto & topic_pair : node_topics->second) {
418418
std::string service_name = _demangle_service_from_topic(topic_pair.first);
419-
if (!service_name.length()) {
419+
if (service_name.empty()) {
420420
// not a service
421421
continue;
422422
}
423423
for (auto & itt : topic_pair.second) {
424424
std::string service_type = _demangle_service_type_only(itt);
425-
if (service_type.length()) {
425+
if (!service_type.empty()) {
426426
services[service_name].insert(service_type);
427427
}
428428
}

rmw_fastrtps_shared_cpp/src/rmw_service_names_and_types.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,13 @@ __rmw_get_service_names_and_types(
7272
std::lock_guard<std::mutex> guard(topic_cache.getMutex());
7373
for (auto it : topic_cache.getTopicToTypes()) {
7474
std::string service_name = _demangle_service_from_topic(it.first);
75-
if (!service_name.length()) {
75+
if (service_name.empty()) {
7676
// not a service
7777
continue;
7878
}
7979
for (auto & itt : it.second) {
8080
std::string service_type = _demangle_service_type_only(itt);
81-
if (service_type.length()) {
81+
if (!service_type.empty()) {
8282
services[service_name].insert(service_type);
8383
}
8484
}

0 commit comments

Comments
 (0)