all: consistently clear prompbmarshal.Label by assigning an empty struct instead of zeroing Name and Value individually

This commit is contained in:
Aliaksandr Valialkin 2024-01-21 05:11:05 +02:00
parent 90768aa418
commit 12f2c5679b
No known key found for this signature in database
GPG key ID: 52C003EE2BCDB9EB
4 changed files with 5 additions and 13 deletions

View file

@ -592,9 +592,7 @@ func GetLabelByName(labels []prompbmarshal.Label, name string) *prompbmarshal.La
// This should help GC cleaning up label.Name and label.Value strings.
func CleanLabels(labels []prompbmarshal.Label) {
for i := range labels {
label := &labels[i]
label.Name = ""
label.Value = ""
labels[i] = prompbmarshal.Label{}
}
}

View file

@ -736,11 +736,9 @@ func (wc *writeRequestCtx) resetNoRows() {
labels := wc.labels
for i := range labels {
label := &labels[i]
label.Name = ""
label.Value = ""
labels[i] = prompbmarshal.Label{}
}
wc.labels = wc.labels[:0]
wc.labels = labels[:0]
wc.samples = wc.samples[:0]
}

View file

@ -282,9 +282,7 @@ func (x *Labels) RemoveLabelsWithDoubleUnderscorePrefix() {
func cleanLabels(labels []prompbmarshal.Label) {
for i := range labels {
label := &labels[i]
label.Name = ""
label.Value = ""
labels[i] = prompbmarshal.Label{}
}
}

View file

@ -252,9 +252,7 @@ func (wr *writeContext) reset() {
func resetLabels(labels []prompbmarshal.Label) []prompbmarshal.Label {
for i := range labels {
label := &labels[i]
label.Name = ""
label.Value = ""
labels[i] = prompbmarshal.Label{}
}
return labels[:0]
}