diff --git a/pkg/tsdb/prometheus/querydata/framing_bench_test.go b/pkg/tsdb/prometheus/querydata/framing_bench_test.go index f1f96e01616..fa63a4fa85d 100644 --- a/pkg/tsdb/prometheus/querydata/framing_bench_test.go +++ b/pkg/tsdb/prometheus/querydata/framing_bench_test.go @@ -41,7 +41,6 @@ func BenchmarkExemplarJson(b *testing.B) { tCtx, err := setup(true) require.NoError(b, err) b.ResetTimer() - b.ReportAllocs() for n := 0; n < b.N; n++ { res := http.Response{ StatusCode: 200, diff --git a/pkg/util/converter/prom.go b/pkg/util/converter/prom.go index a771a9336e4..a71968abf2e 100644 --- a/pkg/util/converter/prom.go +++ b/pkg/util/converter/prom.go @@ -228,8 +228,8 @@ func readArrayData(iter *jsoniter.Iterator) backend.DataResponse { } // For consistent ordering read values to an array not a map -func readLabelsAsPairs(iter *jsoniter.Iterator, pairs [][2]string) [][2]string { - pairs = pairs[:0] +func readLabelsAsPairs(iter *jsoniter.Iterator) [][2]string { + pairs := make([][2]string, 0, 10) for k := iter.ReadObject(); k != ""; k = iter.ReadObject() { pairs = append(pairs, [2]string{k, iter.ReadString()}) } @@ -270,7 +270,7 @@ func readLabelsOrExemplars(iter *jsoniter.Iterator) (*data.Frame, [][2]string) { case "labels": max := 0 - for _, pair := range readLabelsAsPairs(iter, pairs) { + for _, pair := range readLabelsAsPairs(iter) { k := pair[0] v := pair[1] f, ok := lookup[k] @@ -305,7 +305,6 @@ func readLabelsOrExemplars(iter *jsoniter.Iterator) (*data.Frame, [][2]string) { } default: v := fmt.Sprintf("%v", iter.Read()) - pairs = pairs[:0] pairs = append(pairs, [2]string{l1Field, v}) } }