Commit b4a28abf09550000332fc92ac5fcde5eb3e24414
1 parent
cffcf3cf
Small optimization in publishing
Showing
1 changed file
with
4 additions
and
1 deletions
subscriptionstore.cpp
| @@ -75,8 +75,10 @@ void SubscriptionStore::publishRecursively(std::list<std::string>::const_iterato | @@ -75,8 +75,10 @@ void SubscriptionStore::publishRecursively(std::list<std::string>::const_iterato | ||
| 75 | return; | 75 | return; |
| 76 | } | 76 | } |
| 77 | 77 | ||
| 78 | + if (this_node->children.empty()) | ||
| 79 | + return; | ||
| 80 | + | ||
| 78 | std::string cur_subtop = *cur_subtopic_it; | 81 | std::string cur_subtop = *cur_subtopic_it; |
| 79 | - auto sub_node = this_node->children.find(cur_subtop); | ||
| 80 | 82 | ||
| 81 | const auto next_subtopic = ++cur_subtopic_it; | 83 | const auto next_subtopic = ++cur_subtopic_it; |
| 82 | 84 | ||
| @@ -86,6 +88,7 @@ void SubscriptionStore::publishRecursively(std::list<std::string>::const_iterato | @@ -86,6 +88,7 @@ void SubscriptionStore::publishRecursively(std::list<std::string>::const_iterato | ||
| 86 | publishNonRecursively(packet, pound_sign_node->second->subscribers); | 88 | publishNonRecursively(packet, pound_sign_node->second->subscribers); |
| 87 | } | 89 | } |
| 88 | 90 | ||
| 91 | + auto sub_node = this_node->children.find(cur_subtop); | ||
| 89 | if (sub_node != this_node->children.end()) | 92 | if (sub_node != this_node->children.end()) |
| 90 | { | 93 | { |
| 91 | publishRecursively(next_subtopic, end, sub_node->second, packet); | 94 | publishRecursively(next_subtopic, end, sub_node->second, packet); |