From c3518b8c81b7bff23a00a662dc6a086ccb5ba0e8 Mon Sep 17 00:00:00 2001 From: congqixia Date: Wed, 20 Oct 2021 14:26:35 +0800 Subject: [PATCH] Fix nil stats from DeserializeStats (#10255) Signed-off-by: Congqi Xia --- internal/storage/stats.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/internal/storage/stats.go b/internal/storage/stats.go index b9caf53540..3c7e26c0f8 100644 --- a/internal/storage/stats.go +++ b/internal/storage/stats.go @@ -88,8 +88,8 @@ func (sr *StatsReader) GetInt64Stats() (*Int64Stats, error) { } func DeserializeStats(blobs []*Blob) ([]*Int64Stats, error) { - results := make([]*Int64Stats, len(blobs)) - for i, blob := range blobs { + results := make([]*Int64Stats, 0, len(blobs)) + for _, blob := range blobs { if blob.Value == nil { continue } @@ -99,8 +99,7 @@ func DeserializeStats(blobs []*Blob) ([]*Int64Stats, error) { if err != nil { return nil, err } - results[i] = stats + results = append(results, stats) } return results, nil - }