mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
lib/storage: use shorter code after 03bde173b7
This commit is contained in:
parent
38fc55976e
commit
19b189e9b7
1 changed files with 10 additions and 7 deletions
|
@ -1851,12 +1851,13 @@ type pendingMetricRows struct {
|
|||
}
|
||||
|
||||
func (pmrs *pendingMetricRows) reset() {
|
||||
for i := range pmrs.pmrs {
|
||||
pmr := &pmrs.pmrs[i]
|
||||
mrs := pmrs.pmrs
|
||||
for i := range mrs {
|
||||
pmr := &mrs[i]
|
||||
pmr.MetricName = nil
|
||||
pmr.mr = nil
|
||||
}
|
||||
pmrs.pmrs = pmrs.pmrs[:0]
|
||||
pmrs.pmrs = mrs[:0]
|
||||
pmrs.metricNamesBuf = pmrs.metricNamesBuf[:0]
|
||||
pmrs.lastMetricNameRaw = nil
|
||||
pmrs.lastMetricName = nil
|
||||
|
@ -1876,12 +1877,14 @@ func (pmrs *pendingMetricRows) addRow(mr *MetricRow) error {
|
|||
pmrs.lastMetricName = pmrs.metricNamesBuf[metricNamesBufLen:]
|
||||
pmrs.lastMetricNameRaw = mr.MetricNameRaw
|
||||
}
|
||||
if cap(pmrs.pmrs) > len(pmrs.pmrs) {
|
||||
pmrs.pmrs = pmrs.pmrs[:len(pmrs.pmrs)+1]
|
||||
mrs := pmrs.pmrs
|
||||
if cap(mrs) > len(mrs) {
|
||||
mrs = mrs[:len(mrs)+1]
|
||||
} else {
|
||||
pmrs.pmrs = append(pmrs.pmrs, pendingMetricRow{})
|
||||
mrs = append(mrs, pendingMetricRow{})
|
||||
}
|
||||
pmr := &pmrs.pmrs[len(pmrs.pmrs)-1]
|
||||
pmrs.pmrs = mrs
|
||||
pmr := &mrs[len(mrs)-1]
|
||||
pmr.MetricName = pmrs.lastMetricName
|
||||
pmr.mr = mr
|
||||
return nil
|
||||
|
|
Loading…
Reference in a new issue