From 34f5d439eea373da141426f41ee1f32cbffb8549 Mon Sep 17 00:00:00 2001 From: Eugene Chung Date: Wed, 28 Mar 2018 12:58:53 +0900 Subject: [PATCH] remove Heap.Update() call when setting Proposer field In for loop of IncrementAccum(), Heap.Update() call is unnecessary when i == times - 1. --- types/validator_set.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/types/validator_set.go b/types/validator_set.go index 83d066ec1..3885369d3 100644 --- a/types/validator_set.go +++ b/types/validator_set.go @@ -60,13 +60,14 @@ func (valSet *ValidatorSet) IncrementAccum(times int) { // Decrement the validator with most accum times times for i := 0; i < times; i++ { mostest := validatorsHeap.Peek().(*Validator) - if i == times-1 { - valSet.Proposer = mostest - } - // mind underflow mostest.Accum = safeSubClip(mostest.Accum, valSet.TotalVotingPower()) - validatorsHeap.Update(mostest, accumComparable{mostest}) + + if i == times-1 { + valSet.Proposer = mostest + } else { + validatorsHeap.Update(mostest, accumComparable{mostest}) + } } }