Merge pull request #279 from bakins/format-key-optimization

mapper cache: Use string concatenation rather than Sprintf for formatKey
This commit is contained in:
Matthias Rampke 2020-01-01 09:55:02 +01:00 committed by GitHub
commit 2e3d3ab962
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -14,8 +14,7 @@
package mapper package mapper
import ( import (
"fmt" lru "github.com/hashicorp/golang-lru"
"github.com/hashicorp/golang-lru"
"github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus"
) )
@ -81,7 +80,7 @@ func (m *MetricMapperLRUCache) trackCacheLength() {
} }
func formatKey(metricString string, metricType MetricType) string { func formatKey(metricString string, metricType MetricType) string {
return fmt.Sprintf("%s.%s", string(metricType), metricString) return string(metricType) + "." + metricString
} }
func NewMetricMapperNoopCache() *MetricMapperNoopCache { func NewMetricMapperNoopCache() *MetricMapperNoopCache {