From 76ad19f4113c5bf39cb82aaf9f4d557315d3b9df Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Mon, 6 Apr 2015 19:41:55 -0700 Subject: Use binary_search for multicast groups, which are kept in sorted order. --- node/Network.hpp | 23 +++-------------------- 1 file changed, 3 insertions(+), 20 deletions(-) (limited to 'node/Network.hpp') diff --git a/node/Network.hpp b/node/Network.hpp index fa76152b..930d1538 100644 --- a/node/Network.hpp +++ b/node/Network.hpp @@ -100,31 +100,14 @@ public: /** * @return All multicast groups including learned groups that are behind any bridges we're attached to */ - inline std::vector allMulticastGroups() const - { - Mutex::Lock _l(_lock); - std::vector mgs(_myMulticastGroups); - for(std::map< MulticastGroup,uint64_t >::const_iterator i(_multicastGroupsBehindMe.begin());i!=_multicastGroupsBehindMe.end();++i) { - if (std::find(mgs.begin(),mgs.end(),i->first) == mgs.end()) - mgs.push_back(i->first); - } - std::sort(mgs.begin(),mgs.end()); - return mgs; - } + std::vector allMulticastGroups() const; /** * @param mg Multicast group + * @param includeBridgedGroups If true, also include any groups we've learned via bridging * @return True if this network endpoint / peer is a member */ - bool subscribedToMulticastGroup(const MulticastGroup &mg,bool includeBridgedGroups) const - { - Mutex::Lock _l(_lock); - if (std::find(_myMulticastGroups.begin(),_myMulticastGroups.end(),mg) != _myMulticastGroups.end()) - return true; - else if (includeBridgedGroups) - return (_multicastGroupsBehindMe.find(mg) != _multicastGroupsBehindMe.end()); - else return false; - } + bool subscribedToMulticastGroup(const MulticastGroup &mg,bool includeBridgedGroups) const; /** * Subscribe to a multicast group -- cgit v1.2.3