From 619eb595bafb3c0b2b1d94c22be1bd74a65c1a7c Mon Sep 17 00:00:00 2001 From: beorn7 Date: Thu, 6 Dec 2018 11:37:34 +0100 Subject: [PATCH] Simplify an `append` to `copy` Signed-off-by: beorn7 --- prometheus/registry.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/prometheus/registry.go b/prometheus/registry.go index 8301fc8..b5e70b9 100644 --- a/prometheus/registry.go +++ b/prometheus/registry.go @@ -909,8 +909,8 @@ func checkDescConsistency( } // Is the desc consistent with the content of the metric? - lpsFromDesc := make([]*dto.LabelPair, 0, len(dtoMetric.Label)) - lpsFromDesc = append(lpsFromDesc, desc.constLabelPairs...) + lpsFromDesc := make([]*dto.LabelPair, len(desc.constLabelPairs), len(dtoMetric.Label)) + copy(lpsFromDesc, desc.constLabelPairs) for _, l := range desc.variableLabels { lpsFromDesc = append(lpsFromDesc, &dto.LabelPair{ Name: proto.String(l),