From d4a46234c26f94a5ca80be683ca15c25e3948e97 Mon Sep 17 00:00:00 2001 From: clemahieu Date: Fri, 27 Jan 2017 10:42:31 -0600 Subject: [PATCH] Using remove_if. --- rai/node/wallet.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/rai/node/wallet.cpp b/rai/node/wallet.cpp index e8c1412a78..f54ba024fe 100644 --- a/rai/node/wallet.cpp +++ b/rai/node/wallet.cpp @@ -108,14 +108,20 @@ void rai::work_pool::loop (uint64_t thread) void rai::work_pool::cancel (rai::uint256_union const & root_a) { std::lock_guard lock (mutex); - for (auto i (pending.begin ()), n (pending.end ()); i != n; ++i) + pending.remove_if ([&root_a] (decltype (pending)::value_type const & item_a) { - if (i->first == root_a) + bool result; + if (item_a.first == root_a) { - i->second->set_value (boost::none); - pending.erase (i); + item_a.second->set_value (boost::none); + result = true; } - }; + else + { + result = false; + } + return result; + }); } bool rai::work_pool::work_validate (rai::block_hash const & root_a, uint64_t work_a)