mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
lib/promscrape/discoveryutils: always store just allocated string to sanitized label names cache
This is a follow-up for c06e7a142c
This commit is contained in:
parent
c06e7a142c
commit
30b8d91727
1 changed files with 5 additions and 0 deletions
|
@ -29,6 +29,11 @@ func SanitizeLabelName(name string) string {
|
||||||
// Make a copy of name in order to limit memory usage to the name length,
|
// Make a copy of name in order to limit memory usage to the name length,
|
||||||
// since the name may point to bigger string.
|
// since the name may point to bigger string.
|
||||||
s := string(append([]byte{}, name...))
|
s := string(append([]byte{}, name...))
|
||||||
|
if sanitizedName == name {
|
||||||
|
// point sanitizedName to just allocated s, since it may point to name,
|
||||||
|
// which, in turn, can point to bigger string.
|
||||||
|
sanitizedName = s
|
||||||
|
}
|
||||||
sp := &sanitizedName
|
sp := &sanitizedName
|
||||||
m.Store(s, sp)
|
m.Store(s, sp)
|
||||||
n := atomic.AddUint64(&sanitizedLabelNamesLen, 1)
|
n := atomic.AddUint64(&sanitizedLabelNamesLen, 1)
|
||||||
|
|
Loading…
Reference in a new issue