From 02c5f774848f7b56f798928d840c0a10e6f8d6f1 Mon Sep 17 00:00:00 2001 From: Ryan Leung Date: Mon, 18 Jan 2021 12:19:51 +0800 Subject: [PATCH] remove some unused code (#3363) Signed-off-by: rleungx --- pkg/movingaverage/time_median.go | 10 ++++------ server/statistics/hot_peer_cache.go | 2 +- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/pkg/movingaverage/time_median.go b/pkg/movingaverage/time_median.go index fb22e09bd5a..a850c0fccb4 100644 --- a/pkg/movingaverage/time_median.go +++ b/pkg/movingaverage/time_median.go @@ -20,7 +20,6 @@ import "time" // Delay is aotSize * mfSize * reportInterval/4 // and the min filled period is aotSize * reportInterval, which is not related with mfSize type TimeMedian struct { - aotInterval time.Duration aot *AvgOverTime mf *MedianFilter aotSize int @@ -31,11 +30,10 @@ type TimeMedian struct { // NewTimeMedian returns a TimeMedian with given size. func NewTimeMedian(aotSize, mfSize int, reportInterval time.Duration) *TimeMedian { return &TimeMedian{ - aotInterval: reportInterval, - aot: NewAvgOverTime(time.Duration(aotSize) * reportInterval), - mf: NewMedianFilter(mfSize), - aotSize: aotSize, - mfSize: mfSize, + aot: NewAvgOverTime(time.Duration(aotSize) * reportInterval), + mf: NewMedianFilter(mfSize), + aotSize: aotSize, + mfSize: mfSize, } } diff --git a/server/statistics/hot_peer_cache.go b/server/statistics/hot_peer_cache.go index bfa08dc8393..91b719c0749 100644 --- a/server/statistics/hot_peer_cache.go +++ b/server/statistics/hot_peer_cache.go @@ -377,7 +377,7 @@ func (f *hotPeerCache) getDefaultTimeMedian() *movingaverage.TimeMedian { } func (f *hotPeerCache) updateHotPeerStat(newItem, oldItem *HotPeerStat, bytes, keys float64, interval time.Duration) *HotPeerStat { - if newItem == nil || newItem.needDelete { + if newItem.needDelete { return newItem }