From e700cd0bc885340563df9e6b7a5b6c6603b8c984 Mon Sep 17 00:00:00 2001 From: Jeremy Rubin Date: Sun, 19 Jun 2016 21:42:15 -0400 Subject: Convert ForEachNode* functions to take a templated function argument rather than a std::function to eliminate std::function overhead --- src/net.cpp | 73 ------------------------------------------------------------- 1 file changed, 73 deletions(-) (limited to 'src/net.cpp') diff --git a/src/net.cpp b/src/net.cpp index bf5cc07db1..19c14e105e 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -2697,79 +2697,6 @@ bool CConnman::ForNode(NodeId id, std::function func) return found != nullptr && func(found); } -bool CConnman::ForEachNodeContinueIf(std::function func) -{ - LOCK(cs_vNodes); - for (auto&& node : vNodes) - if(!func(node)) - return false; - return true; -} - -bool CConnman::ForEachNodeContinueIf(std::function func) const -{ - LOCK(cs_vNodes); - for (const auto& node : vNodes) - if(!func(node)) - return false; - return true; -} - -bool CConnman::ForEachNodeContinueIfThen(std::function pre, std::function post) -{ - bool ret = true; - LOCK(cs_vNodes); - for (auto&& node : vNodes) - if(!pre(node)) { - ret = false; - break; - } - post(); - return ret; -} - -bool CConnman::ForEachNodeContinueIfThen(std::function pre, std::function post) const -{ - bool ret = true; - LOCK(cs_vNodes); - for (const auto& node : vNodes) - if(!pre(node)) { - ret = false; - break; - } - post(); - return ret; -} - -void CConnman::ForEachNode(std::function func) -{ - LOCK(cs_vNodes); - for (auto&& node : vNodes) - func(node); -} - -void CConnman::ForEachNode(std::function func) const -{ - LOCK(cs_vNodes); - for (const auto& node : vNodes) - func(node); -} - -void CConnman::ForEachNodeThen(std::function pre, std::function post) -{ - LOCK(cs_vNodes); - for (auto&& node : vNodes) - pre(node); - post(); -} - -void CConnman::ForEachNodeThen(std::function pre, std::function post) const -{ - LOCK(cs_vNodes); - for (const auto& node : vNodes) - pre(node); - post(); -} int64_t PoissonNextSend(int64_t nNow, int average_interval_seconds) { return nNow + (int64_t)(log1p(GetRand(1ULL << 48) * -0.0000000000000035527136788 /* -1/2^48 */) * average_interval_seconds * -1000000.0 + 0.5); } -- cgit v1.2.3