mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-24 05:04:05 -08:00
promql: extract function to initialize LabelBuilder
Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
This commit is contained in:
parent
ccea61c7bf
commit
2c382f5e24
|
@ -1032,6 +1032,14 @@ type EvalNodeHelper struct {
|
|||
resultMetric map[string]labels.Labels
|
||||
}
|
||||
|
||||
func (enh *EvalNodeHelper) resetBuilder(lbls labels.Labels) {
|
||||
if enh.lb == nil {
|
||||
enh.lb = labels.NewBuilder(lbls)
|
||||
} else {
|
||||
enh.lb.Reset(lbls)
|
||||
}
|
||||
}
|
||||
|
||||
// DropMetricName is a cached version of DropMetricName.
|
||||
func (enh *EvalNodeHelper) DropMetricName(l labels.Labels) labels.Labels {
|
||||
if enh.Dmn == nil {
|
||||
|
@ -2152,12 +2160,7 @@ func resultMetric(lhs, rhs labels.Labels, op parser.ItemType, matching *parser.V
|
|||
enh.resultMetric = make(map[string]labels.Labels, len(enh.Out))
|
||||
}
|
||||
|
||||
if enh.lb == nil {
|
||||
enh.lb = labels.NewBuilder(lhs)
|
||||
} else {
|
||||
enh.lb.Reset(lhs)
|
||||
}
|
||||
|
||||
enh.resetBuilder(lhs)
|
||||
buf := bytes.NewBuffer(enh.lblResultBuf[:0])
|
||||
enh.lblBuf = lhs.Bytes(enh.lblBuf)
|
||||
buf.Write(enh.lblBuf)
|
||||
|
|
Loading…
Reference in a new issue