patch from @udjinm6 -- extract hash calc from loop (#1119)

calculate hash once before entering loop, should make it around an order of magnitude faster
This commit is contained in:
Nathan Marley 2016-10-31 11:20:49 -07:00 committed by UdjinM6
parent b3f14b3c30
commit 4894345a58

View File

@ -1125,12 +1125,13 @@ int CGovernanceManager::CountMatchingVotes(CGovernanceObject& govobj, vote_signa
LOCK(cs); LOCK(cs);
int nCount = 0; int nCount = 0;
uint256 hash = govobj.GetHash();
std::map<uint256, CGovernanceVote>::iterator it = mapVotesByType.begin(); std::map<uint256, CGovernanceVote>::iterator it = mapVotesByType.begin();
while(it != mapVotesByType.end()) { while(it != mapVotesByType.end()) {
if(it->second.IsValid() && if(it->second.IsValid() &&
it->second.GetSignal() == eVoteSignalIn && it->second.GetSignal() == eVoteSignalIn &&
it->second.GetOutcome() == eVoteOutcomeIn && it->second.GetOutcome() == eVoteOutcomeIn &&
it->second.GetParentHash() == govobj.GetHash()) { it->second.GetParentHash() == hash) {
++nCount; ++nCount;
} }
++it; ++it;