Skip to content

Commit d7f876e

Browse files
committed
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.
1 parent 23aa079 commit d7f876e

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

src/instantx.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1150,10 +1150,7 @@ bool CTxLockVote::IsFailed() const
11501150

11511151
bool COutPointLock::AddVote(const CTxLockVote& vote)
11521152
{
1153-
if(mapMasternodeVotes.count(vote.GetMasternodeOutpoint()))
1154-
return false;
1155-
mapMasternodeVotes.insert(std::make_pair(vote.GetMasternodeOutpoint(), vote));
1156-
return true;
1153+
return mapMasternodeVotes.emplace(std::make_pair(vote.GetMasternodeOutpoint(), vote)).second;
11571154
}
11581155

11591156
std::vector<CTxLockVote> COutPointLock::GetVotes() const

0 commit comments

Comments
 (0)