From b07200812829fa8b2322d665dc45a5f4e28963d1 Mon Sep 17 00:00:00 2001 From: Ryan Leung Date: Tue, 6 Dec 2022 17:28:03 +0800 Subject: [PATCH] statistics: reduce the call times of `DefaultAntiCount` (#5760) ref tikv/pd#5692 Signed-off-by: Ryan Leung --- server/statistics/hot_peer_cache.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/server/statistics/hot_peer_cache.go b/server/statistics/hot_peer_cache.go index 1b0a1481d90..b55df21133e 100644 --- a/server/statistics/hot_peer_cache.go +++ b/server/statistics/hot_peer_cache.go @@ -98,11 +98,12 @@ func NewHotPeerCache(kind RWType) *hotPeerCache { // RegionStats returns hot items func (f *hotPeerCache) RegionStats(minHotDegree int) map[uint64][]*HotPeerStat { res := make(map[uint64][]*HotPeerStat) + defaultAntiCount := f.kind.DefaultAntiCount() for storeID, peers := range f.peersOfStore { values := peers.GetAll() stat := make([]*HotPeerStat, 0, len(values)) for _, v := range values { - if peer := v.(*HotPeerStat); peer.HotDegree >= minHotDegree && !peer.inCold && peer.AntiCount == f.kind.DefaultAntiCount() { + if peer := v.(*HotPeerStat); peer.HotDegree >= minHotDegree && !peer.inCold && peer.AntiCount == defaultAntiCount { stat = append(stat, peer) } }