From 4894345a58d988c5dec0a0b104487b4fa2644e04 Mon Sep 17 00:00:00 2001 From: Nathan Marley Date: Mon, 31 Oct 2016 11:20:49 -0700 Subject: [PATCH] patch from @udjinm6 -- extract hash calc from loop (#1119) calculate hash once before entering loop, should make it around an order of magnitude faster --- src/governance.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/governance.cpp b/src/governance.cpp index 2958ca8ae1..80e18e413b 100644 --- a/src/governance.cpp +++ b/src/governance.cpp @@ -1125,12 +1125,13 @@ int CGovernanceManager::CountMatchingVotes(CGovernanceObject& govobj, vote_signa LOCK(cs); int nCount = 0; + uint256 hash = govobj.GetHash(); std::map::iterator it = mapVotesByType.begin(); while(it != mapVotesByType.end()) { if(it->second.IsValid() && it->second.GetSignal() == eVoteSignalIn && it->second.GetOutcome() == eVoteOutcomeIn && - it->second.GetParentHash() == govobj.GetHash()) { + it->second.GetParentHash() == hash) { ++nCount; } ++it;