Skip to content

Commit

Permalink
replace map count/insert w/emplace in instantx.cpp (#2165)
Browse files Browse the repository at this point in the history
* replace map count/insert w/emplace in instantx.cpp

This feels like an optimization, something about:

```
if map.count(key)
     return false
else
     insert(pair)
     return true
```

... just feels icky. Plus, `vote.GetMasternodeOutpoint()` is only called
once. The previous version might be slightly more readable, however.

* use std::pair template constructor shortcut
  • Loading branch information
nmarley authored and UdjinM6 committed Jul 12, 2018
1 parent fd70a1e commit 42c193d
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions src/instantx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1146,10 +1146,7 @@ bool CTxLockVote::IsFailed() const

bool COutPointLock::AddVote(const CTxLockVote& vote)
{
if(mapMasternodeVotes.count(vote.GetMasternodeOutpoint()))
return false;
mapMasternodeVotes.insert(std::make_pair(vote.GetMasternodeOutpoint(), vote));
return true;
return mapMasternodeVotes.emplace(vote.GetMasternodeOutpoint(), vote).second;
}

std::vector<CTxLockVote> COutPointLock::GetVotes() const
Expand Down

0 comments on commit 42c193d

Please sign in to comment.