Commit 44de6670380a6030719f95efc18b4b7c36d26644

Authored by Wiebe Cazemier
1 parent 756289d4

Make recursive publish methods static

They don't need object state.
subscriptionstore.cpp
@@ -383,7 +383,7 @@ void SubscriptionStore::queueWillMessage(const std::shared_ptr<WillPublish> &wil @@ -383,7 +383,7 @@ void SubscriptionStore::queueWillMessage(const std::shared_ptr<WillPublish> &wil
383 } 383 }
384 384
385 void SubscriptionStore::publishNonRecursively(const std::unordered_map<std::string, Subscription> &subscribers, 385 void SubscriptionStore::publishNonRecursively(const std::unordered_map<std::string, Subscription> &subscribers,
386 - std::forward_list<ReceivingSubscriber> &targetSessions) const 386 + std::forward_list<ReceivingSubscriber> &targetSessions)
387 { 387 {
388 for (auto &pair : subscribers) 388 for (auto &pair : subscribers)
389 { 389 {
@@ -410,7 +410,7 @@ void SubscriptionStore::publishNonRecursively(const std::unordered_map&lt;std::stri @@ -410,7 +410,7 @@ void SubscriptionStore::publishNonRecursively(const std::unordered_map&lt;std::stri
410 * look at objdump --disassemble --demangle to see how many calls (not jumps) to itself are made and compare. 410 * look at objdump --disassemble --demangle to see how many calls (not jumps) to itself are made and compare.
411 */ 411 */
412 void SubscriptionStore::publishRecursively(std::vector<std::string>::const_iterator cur_subtopic_it, std::vector<std::string>::const_iterator end, 412 void SubscriptionStore::publishRecursively(std::vector<std::string>::const_iterator cur_subtopic_it, std::vector<std::string>::const_iterator end,
413 - SubscriptionNode *this_node, std::forward_list<ReceivingSubscriber> &targetSessions) const 413 + SubscriptionNode *this_node, std::forward_list<ReceivingSubscriber> &targetSessions)
414 { 414 {
415 if (cur_subtopic_it == end) // This is the end of the topic path, so look for subscribers here. 415 if (cur_subtopic_it == end) // This is the end of the topic path, so look for subscribers here.
416 { 416 {
subscriptionstore.h
@@ -125,10 +125,10 @@ class SubscriptionStore @@ -125,10 +125,10 @@ class SubscriptionStore
125 125
126 Logger *logger = Logger::getInstance(); 126 Logger *logger = Logger::getInstance();
127 127
128 - void publishNonRecursively(const std::unordered_map<std::string, Subscription> &subscribers,  
129 - std::forward_list<ReceivingSubscriber> &targetSessions) const;  
130 - void publishRecursively(std::vector<std::string>::const_iterator cur_subtopic_it, std::vector<std::string>::const_iterator end,  
131 - SubscriptionNode *this_node, std::forward_list<ReceivingSubscriber> &targetSessions) const; 128 + static void publishNonRecursively(const std::unordered_map<std::string, Subscription> &subscribers,
  129 + std::forward_list<ReceivingSubscriber> &targetSessions);
  130 + static void publishRecursively(std::vector<std::string>::const_iterator cur_subtopic_it, std::vector<std::string>::const_iterator end,
  131 + SubscriptionNode *this_node, std::forward_list<ReceivingSubscriber> &targetSessions);
132 void giveClientRetainedMessagesRecursively(std::vector<std::string>::const_iterator cur_subtopic_it, 132 void giveClientRetainedMessagesRecursively(std::vector<std::string>::const_iterator cur_subtopic_it,
133 std::vector<std::string>::const_iterator end, RetainedMessageNode *this_node, bool poundMode, 133 std::vector<std::string>::const_iterator end, RetainedMessageNode *this_node, bool poundMode,
134 std::forward_list<Publish> &packetList) const; 134 std::forward_list<Publish> &packetList) const;