From a00db4267c99726f12cf96a6723fafbd33ac451c Mon Sep 17 00:00:00 2001 From: Eng Zer Jun Date: Sun, 17 Sep 2023 10:09:29 +0800 Subject: [PATCH] data-usage-cache: remove redundant nil check (#17970) From the Go specification: "3. If the map is nil, the number of iterations is 0." [1] Therefore, an additional nil check for before the loop is unnecessary. [1]: https://go.dev/ref/spec#For_range Signed-off-by: Eng Zer Jun --- cmd/data-usage-cache.go | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/cmd/data-usage-cache.go b/cmd/data-usage-cache.go index 59048d48a..f6e1895c8 100644 --- a/cmd/data-usage-cache.go +++ b/cmd/data-usage-cache.go @@ -347,20 +347,18 @@ func (e *dataUsageEntry) addSizes(summary sizeSummary) { e.ReplicationStats.ReplicaSize += uint64(summary.replicaSize) e.ReplicationStats.ReplicaCount += uint64(summary.replicaCount) - if summary.replTargetStats != nil { - for arn, st := range summary.replTargetStats { - tgtStat, ok := e.ReplicationStats.Targets[arn] - if !ok { - tgtStat = replicationStats{} - } - tgtStat.PendingSize += uint64(st.pendingSize) - tgtStat.FailedSize += uint64(st.failedSize) - tgtStat.ReplicatedSize += uint64(st.replicatedSize) - tgtStat.ReplicatedCount += uint64(st.replicatedCount) - tgtStat.FailedCount += st.failedCount - tgtStat.PendingCount += st.pendingCount - e.ReplicationStats.Targets[arn] = tgtStat + for arn, st := range summary.replTargetStats { + tgtStat, ok := e.ReplicationStats.Targets[arn] + if !ok { + tgtStat = replicationStats{} } + tgtStat.PendingSize += uint64(st.pendingSize) + tgtStat.FailedSize += uint64(st.failedSize) + tgtStat.ReplicatedSize += uint64(st.replicatedSize) + tgtStat.ReplicatedCount += uint64(st.replicatedCount) + tgtStat.FailedCount += st.failedCount + tgtStat.PendingCount += st.pendingCount + e.ReplicationStats.Targets[arn] = tgtStat } if summary.tiers != nil { if e.AllTierStats == nil {