diff options
| author | Adam Ierymenko <adam.ierymenko@gmail.com> | 2015-04-06 19:41:55 -0700 |
|---|---|---|
| committer | Adam Ierymenko <adam.ierymenko@gmail.com> | 2015-04-06 19:41:55 -0700 |
| commit | 76ad19f4113c5bf39cb82aaf9f4d557315d3b9df (patch) | |
| tree | ca59e43064d100b13c1c7a399e134b351e5319e0 /node/Network.hpp | |
| parent | 758bf949db708358b1ad82297fc859b16cb3c4d2 (diff) | |
| download | infinitytier-76ad19f4113c5bf39cb82aaf9f4d557315d3b9df.tar.gz infinitytier-76ad19f4113c5bf39cb82aaf9f4d557315d3b9df.zip | |
Use binary_search for multicast groups, which are kept in sorted order.
Diffstat (limited to 'node/Network.hpp')
| -rw-r--r-- | node/Network.hpp | 23 |
1 files changed, 3 insertions, 20 deletions
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<MulticastGroup> allMulticastGroups() const - { - Mutex::Lock _l(_lock); - std::vector<MulticastGroup> 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<MulticastGroup> 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 |
