mirror of
https://github.com/coredns/coredns.git
synced 2025-10-28 00:34:24 -04:00
perf: avoid string concatenation in loops (#7572)
* perf: avoid string concatenation in loops Apply perfpsrint linter Signed-off-by: Philippe Antoine <contact@catenacyber.fr> * ci: enable perfsprint Signed-off-by: Philippe Antoine <contact@catenacyber.fr> --------- Signed-off-by: Philippe Antoine <contact@catenacyber.fr>
This commit is contained in:
@@ -157,14 +157,14 @@ func newMetricFamily(dtoMF *dto.MetricFamily) *MetricFamily {
|
||||
mf.Metrics[i] = summary{
|
||||
Labels: makeLabels(m),
|
||||
Quantiles: makeQuantiles(m),
|
||||
Count: fmt.Sprint(m.GetSummary().GetSampleCount()),
|
||||
Count: strconv.FormatUint(m.GetSummary().GetSampleCount(), 10),
|
||||
Sum: fmt.Sprint(m.GetSummary().GetSampleSum()),
|
||||
}
|
||||
} else if dtoMF.GetType() == dto.MetricType_HISTOGRAM {
|
||||
mf.Metrics[i] = histogram{
|
||||
Labels: makeLabels(m),
|
||||
Buckets: makeBuckets(m),
|
||||
Count: fmt.Sprint(m.GetHistogram().GetSampleCount()),
|
||||
Count: strconv.FormatUint(m.GetHistogram().GetSampleCount(), 10),
|
||||
Sum: fmt.Sprint(m.GetSummary().GetSampleSum()),
|
||||
}
|
||||
} else {
|
||||
@@ -209,7 +209,7 @@ func makeQuantiles(m *dto.Metric) map[string]string {
|
||||
func makeBuckets(m *dto.Metric) map[string]string {
|
||||
result := map[string]string{}
|
||||
for _, b := range m.GetHistogram().GetBucket() {
|
||||
result[fmt.Sprint(b.GetUpperBound())] = fmt.Sprint(b.GetCumulativeCount())
|
||||
result[fmt.Sprint(b.GetUpperBound())] = strconv.FormatUint(b.GetCumulativeCount(), 10)
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user