mirror of
https://github.com/minio/minio.git
synced 2025-04-18 17:55:28 -04:00
Remove empty replication stats when sending update (#19375)
When sending update and there is no replication stats - remove the struct. Will remove an unneeded alloc on the receiver.
This commit is contained in:
parent
d63e603040
commit
aa0eec16ab
@ -191,6 +191,22 @@ type replicationAllStatsV1 struct {
|
|||||||
ReplicaCount uint64 `msg:"ReplicaCount,omitempty"`
|
ReplicaCount uint64 `msg:"ReplicaCount,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// empty returns true if the replicationAllStats is empty (contains no entries).
|
||||||
|
func (r *replicationAllStats) empty() bool {
|
||||||
|
if r == nil {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
if r.ReplicaSize != 0 || r.ReplicaCount != 0 {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
for _, v := range r.Targets {
|
||||||
|
if !v.Empty() {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
// clone creates a deep-copy clone.
|
// clone creates a deep-copy clone.
|
||||||
func (r *replicationAllStats) clone() *replicationAllStats {
|
func (r *replicationAllStats) clone() *replicationAllStats {
|
||||||
if r == nil {
|
if r == nil {
|
||||||
@ -899,6 +915,9 @@ func (d *dataUsageCache) sizeRecursive(path string) *dataUsageEntry {
|
|||||||
return root
|
return root
|
||||||
}
|
}
|
||||||
flat := d.flatten(*root)
|
flat := d.flatten(*root)
|
||||||
|
if flat.ReplicationStats.empty() {
|
||||||
|
flat.ReplicationStats = nil
|
||||||
|
}
|
||||||
return &flat
|
return &flat
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user